TIL 2021.05.08

Solved in: Javascript and Python


27. Remove Element

Given an array nums and a value val, remove all instances of that value in-place and return the new length.

Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

The order of elements can be changed. It doesn’t matter what you leave beyond the new length.


Confused why the returned value is an integer but your answer is an array?

Note that the input array is passed in by reference, which means a modification to…

TIL 2021.05.07

Solved in: Javascript and Python


58. Length of Last Word

Given a string s consists of some words separated by spaces, return the length of the last word in the string. If the last word does not exist, return 0.

A word is a maximal substring consisting of non-space characters only.

Example 1:
Input: s = "Hello World"
Output: 5

Example 2:
Input: s = " "
Output: 0


  • 1 <= s.length <= 104
  • s consists of only English letters and spaces ‘ ‘.

Solution: JavaScript

* @param {string} s
* @return {number}
var lengthOfLastWord…

TIL 2021.05.06

Solved in: Javascript and Python


35. Search Insert Position

Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

Example 1:
Input: nums = [1,3,5,6], target = 5
Output: 2

Example 2:
Input: nums = [1,3,5,6], target = 2
Output: 1

Example 3:
Input: nums = [1,3,5,6], target = 7
Output: 4

Example 4:
Input: nums = [1,3,5,6], target = 0
Output: 0

Example 5:
Input: nums = [1], target = 0

TIL 2021.05.05

Solved in: Javascript and Python


13. Roman to Integer

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.

Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000

For example, 2 is written as II in Roman numeral, just two one’s added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II.

Roman numerals are usually written largest to smallest from left to right. However, the numeral for…

TIL 2021.05.04

Solved in: Javascript and Python

9. Palindrome Number

Given an integer x, return true if x is palindrome integer.

An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not.

Example 1:

Input: x = 121
Output: true

Example 2:
Input: x = -121
Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.

Example 3:
Input: x = 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.

Example 4:
Input: x = -101
Output: false

TIL 2021.05.03

Solved in: JavaScript and Python


1. Two Sum

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

Example 1:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Output: Because nums[0] + nums[1] == 9, we return [0, 1].
Example 2:
Input: nums = [3,2,4], target = 6
Output: [1,2]
Example 3:
Input: nums = [3,3]…

Working on: Tweeter App (Twitter Clone)


  • Is one of the methods that can be used on the CollectionReference Object alongside other methods such as add, get and more.
  • Attaches a listener and listens for any operational changes on our Firestore database (in real time) — such as CRUD (Create, Read, Update and Delete) operations.

First of all, to be able to use onSnapshot we need to access the CollectionReference object through:


collection() gets a CollectionReference instance that refers to the collection at the specified path. …

Working on: Tweeter (Twitter Clone App)


Using Firebase, we can sign in with Firebase’s signInWithPopUp() which takes an OAuth provider as a parameter. signInWithPopUp authenticates a Firebase client using pop-up based OAuth authentication flow — if successful, it returns the signed in user along with the provider’s credentials. If not, it will return an object containing the error message. (Definition retrieved from Firebase Documentation).

To use signInWithPopUp we first have to create a provider.

To be able to create a provider we have to access firebase.auth. On my firebase.js file:

import firebase from "firebase/app";import "firebase/auth";const firebaseConfig =…

TIL 2021.02.25

Day 77: Treehouse Full Stack JavaScript Techdegree

As developers, we need to ensure that the data created and updated by users is reliable without irrelevant or duplicate entries.

We can use Sequelize’s validation and constraint capabilities.

Sequelize can run validation on a model to require specific values and define constraints to prevent incorrect, unexpected or potentially harmful data from being recorded into the database

Right now if we submit or post a new user, it will be created with null values. Because we haven’t made any validation/constraint configurations on the user model

This is our user model

TIL 2021.02.24

Day 76: Treehouse Full Stack JavaScript Techdegree



Traditional Web Applications

  • Handles both server side and client side concerns
  • Example: Favorite Recipes Web App
  • Click on a URL and the browser makes a request to the server and the server responds by finding the recipe data in a database, assembling the data into HTML templates and sending that HTML back to the browser to be displayed.
  • But what if we want to do the same with a mobile app? This is where REST API comes in

When we request information from a RESTful Application, the…

Renzo Regio

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store