This question has come up a few times during technical interviews, but revolves around a single algorithm that appears quite often throughout many algorithm problems — name hashmaps.

A hashmap is an object in Javascript that has a key and value pair that can be used to keep a running count of items.

The first thing you should be doing if you come across this problem is asking what a palindrome is defined in terms of letters. We all know that a palindrome can be read forward and backwards — popular examples being ‘racecar’ and ‘a man a plan a…

For day 15, the problem is quite tricky as the order of operations is difficult to nail down.

You are given an array of numbers — and in this case an array of length 3. The function goes as such — the array of numbers is iterated through and every subsequent number checks the count of the number that went previously. If the previous number has only appeared once, then the next number is zero. If it has appeared more than once, then the next number is the current iteration subtracted by the previous occurrence of the number.

In the…

For day 13, you are given an input that is two lines. The first line contains a number that represents a time. The second line contains a string that has bus IDs that are separated with commas that take you to the destination. Each number in the string represents the amount of time it takes to make a full trip and return to its origin.

The problem is to find the earliest bus that will take you to the destination. In other words, assuming that you are leaving at the time represented in the first time, which bus will arrive…

For day 12, you are given a set of direction and and you need to maintain the X and Y position from the origin. It also asks you to keep track of the direction that you are facing. Initially, you are facing east and will be turning in increments of 90 degrees to face a different direction.

N - Move north x units
S - Move south x units
E - Move east x units
W - Move west x units
L - Turn left y degrees
R - Turn right y degrees
F - Move forward based on direction…

For day 10, the explanation of the problem is a bit convoluted and can be simplified quite a bit. The input given is an unordered list of unique numbers where each number accepts a value within the list that is between 1 and 3 lower than the current value.

The question asks for the number of differences of 1 and the number of differences of 3. If this does not make sense, we can take a look at the sample data.


Assuming that the count starts at zero, the…

For day 9, you are given a list of numbers. Starting from 26th indexed number, every number indexed further down is the sum of two numbers in the previous 25 numbers. The problem asks for which number is not a sum of any combination of the previous 25 numbers.

For the sample data, we will be starting with the 6th indexed number and the previous 5 numbers.

[1] 35
[2] 20
[3] 15
[4] 25
[5] 47
40 = (Range 1-5) [3] 15 + [4] 25
62 = (Range 2-6) [3] 15 + [5] 47
55 = (Range 3-7) [3] 15 + [6] 40
65 = (Range 4-8)…

For day 8, the input data is a stack of instructions. The stack of instructions, when followed properly, leads to an infinite loop. You are given in the instructions that every line can only be run once and to return the value prior to the start of the second iteration.

The three instructions in the stack are ‘nop’, ‘acc’, and ‘jmp’. The first has no function and should only continue to the next instruction below it. The second will either add or subtract to the current value. …

Today’s puzzle is quite confusing on how to complete. If we take a look at the sample data:

light red bags contain 1 bright white bag, 2 muted yellow bags.
dark orange bags contain 3 bright white bags, 4 muted yellow bags.
bright white bags contain 1 shiny gold bag.
muted yellow bags contain 2 shiny gold bags, 9 faded blue bags.
shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags.
dark olive bags contain 3 faded blue bags, 4 dotted black bags.
vibrant plum bags contain 5 faded blue bags, 6 dotted black bags.
faded blue bags contain no other bags.
dotted black bags…

For Day 6, you are given a string of characters that represent the answer “Yes” to a question labeled with a single character. There are 26 possible possible questions as there are the same number of letters in the alphabet.

In the input data, each person is represented on a new line and each group is represented with an extra space in between the input data. For example, if we were to look at the sample data:






As there are letters on eleven lines, there are eleven people split…

For Day 5, you are asked to use parse through a string of 10 characters which point to a specific seat on a plane. The airplane has 128 rows and 8 seats per row. The first seven characters, made up of F’s and B’s, identify the row of the seat and the last three characters, made up of L’s and R’s identify the seat in the row. Each character halves the possible seats and tells whether to take the first half or the second half. Given the string:


The first F refers to the first half of the 128…

Vincent Yang

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