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!
arr
, move all zeroes in the array to the end of the array. You should preserve the relative order of items in the array.Examples:
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:
arr
→ 0 ≤ arr.length ≤ 20Let's analyze the problem. What we’re doing is pretty simple in concept, if there is a zero value before a…
Firebase is a BaaS (backend as a service) platform developed by Google for creating web and mobile applications. It provides developers a number of tools and services to help develop quality apps and scale over time as their user base increases.
Some notable features Firebase provides:
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!
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
).x
→ 0 ≤ xn
→ 0 < nLet’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.
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.
*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.
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!
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.y
element in the original array.”Let’s analyze and restate the problem in our own words.
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!
So right off the bat, let's analyze the prompt.
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.
Have you ever heard about the ‘Rubber Ducky’?
Just another one of those dreamers with a sparkle in his eyes.