In this article, I’ll be breaking down the moveZerosToEnd problem in a few different ways in Javascript. I’ll walk through my process of solving the problem and discuss its BigO.

Let’s begin!

Question

Given a static-sized array of integers arr, move all zeroes in the array to the end of the array. You should preserve the relative order of items in the array.

We should implement a solution that is more efficient than a naive brute force.

input:  arr = [1, 10, 0, 2, 8, 3, 0, 0, 6, 4, 0, 5, 7, 0]
output: [1, 10, 2, 8, 3, 6, 4, 5, 7, 0, 0, 0, 0, 0]

Constraints:

  • [time limit] 5000ms
  • [input] array.integer arr → 0 ≤ arr.length ≤ 20
  • [output] array.integer

Let's analyze the problem. What we’re doing is pretty simple in concept, if there is a zero value before a…


What is Firebase?

Some notable features Firebase provides:

  • Authentication — Firebase Authentication can be used to manually integrate one or more sign-in methods into an app.
  • Realtime database — data is synced across all clients in real time and remains available even when an app goes offline.
  • Hosting — Firebase provides fast hosting for a web app.
  • Analytics — allows you to…


In this article, I’ll be breaking down the rootOfNumber problem in Javascript. I’ll walk through my process of solving the problem and discuss its BigO.

Let’s begin!

Question:

Implement a function root that calculates the n’th root of a number. The function takes a nonnegative number x and a positive integer n, and returns the positive n’th root of x within an error of 0.001 (i.e. suppose the real root is y, then the error is: |y-root(x,n)| and must satisfy |y-root(x,n)| < 0.001).

Examples:

  • input: x = 7, n = 3 → output: 1.913
  • input: x = 9, n = 2 → output: 3

Constraints:

  • [time limit] 5000ms
  • [input] float x → 0 ≤ x
  • [input] integer n → 0 < n
  • [output] float

Let’s analyze and restate the problem in our own words.

We’re being asked to write a function that determines the n’th root of a number. So what does that mean? …


A quick cheat sheet / mini-quiz on LinkedLists to brush up on the fundamentals.

This blog post will be formatted with a question and then a corresponding answer. I find that having a question posed can help solidify my ability to recall information as well as force me to have a better understanding of the topic. See if it does the same for you.

As you go through the blog try to answer the questions in your own words before looking at the provided answer.

What is a Linked List?

  • A linear data structure with composed of ‘nodes’ that are linked with pointers. They are…

A quick cheat sheet / mini-quiz on HashTables to brush up on the fundamentals.

This blog post will be formatted with a question and then a corresponding answer. I find that having a question posed can help solidify my ability to recall information as well as force me to have a better understanding of the topic. See if it does the same for you.

As you go through the blog try to answer the questions in your own words before looking at the provided answer.

What are some of the other names for a Hash Table?

  • Hash Maps
  • Maps
  • Unordered Maps
  • Dictionaries
  • Objects

*depending on the language there will be slight…


A quick cheat sheet / mini-quiz on Arrays to brush up on the fundamentals.

This blog post will be formatted with a question and then a corresponding answer. I find that having a question posed can help solidify my ability to recall information as well as force me to have a better understanding of the topic. See if it does the same for you.

As you go through the blog try to answer the questions in your own words before looking at the provided answer.

Describe an Array in as many ways as possible.

  • A collection of items of the same data type(typically).
  • Can be multiple dimensions.
  • Can be…


If you’ve been using Redux, or have used it before, but don’t know much about Facebook’s Flux Pattern. Don’t worry about it, you’ll get it in no time.

Here’s the jist.

Flux can be seen as a precursor to Redux. It was created as an alternative to the Model-View-Controller (MVC) pattern due to the number of bugs that arose as applications scaled and became increasingly more complicated.

Furthermore, due to the bi-directional nature of MVC, it makes tracking the source of bugs a big pain, as well lead to instability of the overall architecture.


In this article, I’ll be breaking down the findPairsWithGivenDiff problem in Javascript. I’ll walk through my process and solve the problem in two ways to compare their BigO.

Let's begin!

Directions:

“Given an array arr of distinct integers and a non-negative integer k, write a function findPairsWithGivenDifference that returns an array of all pairs [x,y] in arr, such that x - y = k. If no such pairs exist, return an empty array.

Note: the order of the pairs in the output array should maintain the order of the y element in the original array.”

The inputs are an array of distinct integers and a non-negative integer.

We’d like to know how many pairs provide a difference of the given non-negative integer ‘k’. Such that (x-y) = k.

The outputs should be an array of arrays if such pairs exist. Each sub-array containing the [x, y] values. If no pairs exist return an empty array.


In this article, I’ll be breaking down the hasPairWithSum problem in Javascript. I’ll walk through my process and solve the problem in two ways to compare their BigO.

Lets begin!

Directions: given an array and sum, see if the array has two elements that equate to the given sum

1. is it sorted → no . will the arr only contain integers — -> yes.

2. how large can the array be? is it stored in memory? — -> it can be very large. For now, it is stored in memory

3. are negative numbers allowed? → yes. are duplicates allowed → yes.

4. what is the output? …


Algorithms — especially at the start — are HARD.

Even problems that you can understand, with solutions that conceptually make sense, can be so difficult to write in a way that is optimized and covers all the corner cases.

It can be frustrating, demoralizing, and just plain old confusing.

But hey, it's part of the game and if you’re getting into tech, algorithms are how you get to flex your problem-solving skills.

So here are some notes about how to approach algorithms.

When you’re working through the problem — talk it out.

Janu Sung

Just another one of those dreamers with a sparkle in his eyes.

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