• ## Counting Unival Subtrees

A unival tree (which stands for “universal value”) is a tree where all nodes have the same value.

Given the root to a binary tree, count the number of unival subtrees.

...more
• ## How to Solve the Knight's Tour Problem

Let’s work through the problem of the knight’s tour problem.

A knight’s tour is a sequence of moves by a knight on a chessboard such that all squares are visited once.

Given N, write a function to return the number of knight’s tours on an N by N chessboard.

...more
• ## How to Formulaically Solve Tree Interview Questions

Tree questions are very common at top tech company interviews. I had two tree questions in my Google onsite interviews and one during my Facebook onsite interviews. An awesome thing about them is that they can be formulaically solved every single time. It doesn’t involve any genius insight. Let me show you how.

...more
• ## An Introduction To Backtracking

Backtracking is an effective technique for solving algorithmic problems. In backtracking, we search depth-first for solutions, backtracking to the last valid path as soon as we hit a dead end.

...more
• ## How To Find Arbitrage Opportunities In Python

Hi there!

Let’s solve an interesting programming interview problem: how to find an arbitrage. Here’s the question.

Suppose you are given a table of currency exchange rates, represented as a 2D array. Determine whether there is a possible arbitrage: that is, whether there is some sequence of trades you can make, starting with some amount A of any currency, so that you can end up with some amount greater than A of that currency.

...more
• ## How to Solve the Staircase Problem

Let’s work through the following problem.

There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time.

Given N, write a function that returns the number of unique ways you can climb the staircase.
The order of the steps matters.

...more
• ## The Complete Guide To Getting A Full-Time Software Engineering Job

This post is targeted for people looking to get offers from large tech companies like Google, Facebook, Microsoft, Dropbox, Uber, Lyft, and Airbnb. This isn’t to say other companies aren’t interesting! It’s just that these companies’ interview processes are all straightforward (though not necessarily easy) and many people are interested in working for them.

...more
• ## How to Pick a Random Element from an Infinite Stream

Let’s work through the problem of uniformly picking a random element from a gigantic stream. This is a common interview question at companies like Google and Facebook.

...more
• ## How To Solve a Hard Programming Interview Question

Let’s go over the thought process for solving a tricky coding interview question. I often find it’s not enough to just be able to solve the question; you really need to vocalize your thought process. This shows that you’re a strong communicator and that you didn’t just get lucky solving this one problem.

...more