In this article, we will be solving LeetCode’s The kth Factor of n in JavaScript. I recently did a similar problem for a technical assessment, so I wanted to dive in more into this kind of problem. I found this problem very interesting especially in finding ways to make the runtime quicker. A factor is a number that divides another number completely without leaving any remainder.

Given two positive integers `n`

and `k`

.

A factor of an integer `n`

is defined as an integer `i`

where `n % i == 0`

.

Consider a list of all factors of `n`

sorted…

In this article, we will be solving LeetCode’s Minimum Number of Operations to Move All Balls to Each Box in TypeScript. I have been learning TypeScript over the past couple weeks, so I wanted to try my hand with solving a LeetCode problem in TypeScript. I have two past articles about the basics of TypeScript. In part 1, I covered what Typescript is. Recap, TypeScript is a superset of JavaScript that adds a strong type system and object-oriented programming. This means we can specify types to different variables at the time of declaration. They will always hold the same type…

Welcome back to basics of TypeScript. Part 1 covered what Typescript is. Recap, TypeScript is a superset of JavaScript that adds a robust type system and object-oriented programming. In this article, I will give a look into the core types of TypeScript.

TypeScript can be viewed as JavaScript with type. This means we can specify types to different variables at the time of declaration. They will always hold the same type of data in that scope. This type checking helps to ensure our code works as expected and helps hunt down bugs and errors.

Different from JavaScript, we can define…

Typescript is a language that has been quickly gaining traction in the programming world and something that I have been interested in learning for a while. Therefore, I thought the best way to show what I am learning is to blog about it. Therefore, this is part 1 of my journey into learning TypeScript where I will cover what TypeScript is and static typing.

Typescript is a typed superset of JavaScript and was created by Microsoft in 2012. What does superset mean? JavaScript code is valid Typescript code, but Typescript comes with some additional features like a robust type system…

In this article, we will be solving LeetCode’s ‘Merge Two Binary Trees’ in JavaScript. This problem uses the binary search tree data structure. For a quick definition of a binary search tree (BST), a BST is a data structure in which each node has at most two children. The value of each left node is less than its parent, while the value of each right node is greater than its parent. I linked my article on BST that goes into more detail at the bottom.

You are given two binary trees `root1`

and `root2`

.

Imagine that when you put one…

In this article, we will be solving LeetCode’s ‘Container With Most Water’ problem in JavaScript. This problem uses the two-pointer approach. The two-pointer approach is usually used to keep track of array or string indices to solve a problem. One pointer starts from the beginning while the other pointer starts from the end. The pointers move toward each other until they both meet.

Given `n`

non-negative integers `a1, a2, ..., an`

, where each represents a point at coordinate `(i, ai)`

. `n`

vertical lines are drawn such that the two endpoints of the line `i`

is at `(i, ai)`

and…

In this article, we will be solving LeetCode’s Interval List Intersections in JavaScript. This problem uses the two-pointer approach. The two-pointer approach is usually used to keep track of array or string indices to solve a problem. One variation is one pointer being slow and the other pointer being fast meaning that the fast pointer is ahead of the slow pointer while traversing through the array/string. A classic example of this is to remove duplicates from a sorted array. Another variation is one pointer starts from the beginning while the other pointer starts from the end. The pointers move toward…

In this article, we will be solving LeetCode’s Maximum Number of Vowels in a Substring of Given Length in JavaScript. This problem uses the sliding window technique. There are two types of sliding window. The technique used for this problem is a fixed window length k. We shift the window over to find something specific in the window such as the maximum number in the window. The other technique involves 2 pointers (usually indices of string/array) representing 2 edges on the side of the window. Start index is on the left edge and end index is on the right edge…

`async`

and `await`

are two keywords that can help make asynchronous code read more like synchronous code. This can help code look cleaner while keeping the benefits of asynchronous code. Asynchronous means that things can happen independently of the main program flow. Most programs are asynchronous and pause their execution until they are needed, allowing the computer to execute other things in the meantime.

`async`

and `await`

are functions built on promises. A promise is commonly defined as a proxy for a value that will eventually become available. Promises are one way to deal with asynchronous code.

A `Promise`

is…

In this article, we will be solving LeetCode’s Swapping Nodes in a Linked List in JavaScript.

Here is an article I wrote on Linked Lists and goes through a LeetCode problem.

Recap, a linked list is a linear collection of nodes where each node points to the next node. Each node has a value property and a next property which references the next node in the list.

This is what makes linked lists a linear data structure. There is a sequence and an order to the list. To get to the end of the list, we must start at the…

Flatiron School software engineering alum. Experienced in JavaScript, React.js, Ruby, and Ruby on Rails. https://www.linkedin.com/in/chandler-hanson/