Sign in

Solutions to programming interview questions at some of the top companies in the world:

This simple short post illustrates how Graph problems appear at a variety of places during a coding interview. Today’s problem deals with a Directed Acyclic Graph (DAG), and Topological sorting of a DAG. The problem was asked by Airbnb.

Feel free to look at some of the older graph theory problems and their solutions.


We’re given a hashmap associating each courseId key with a list of courseIds values, which represents that the prerequisites of courseId are courseIds. Return a sorted ordering of courses such that we can finish all courses. Return empty if there is no such ordering.

For example…

Bit manipulation and bitwise operators are some of the hardest problems in programming interviews. This post discusses an interesting bit manipulation problem. The problem was asked by Salesforce.


Given an array, find the maximum AND value generated by any pair of element from the array.


Input : arr[] = {4, 8, 12, 16} 
Output : Maximum AND value = 8
Input : arr[] = {4, 8, 16, 2}
Output : Maximum AND value = 0

(Recall that & is a bitwise AND operator in C++).

Solution 1: Naive approach

Recall the truth table of the logical AND operator

The AND of two bits…

Data structure manipulation comes up pretty frequently in programming interview questions. This post discusses manipulating a linked list to design stacks. The problem was asked in a programming interview by Microsoft.

This post also adds more robustness to the implementation by using C++ language support (iterators and templates). A command over standard language constructs makes your interview stand out, and gives you an extra edge in the hiring process!


Implement three stacks using one Linked List.

Solution 1: Pointer Management

The basic algorithm should be easy after a moment’s thought. Here is the diagram that explains it!

Some of the most interesting programming interview questions are based on arrays. The inputs of these interview questions are simple arrays of integers or floating point numbers. Your task, as a candidate, is to perform some operations on these numbers (maybe find the most frequently occuring one, or the largest sum among the arrays; or, find the most optimal floating point adjustments to the array, as today’s problem demands).

Most array based problems are easy to state and understand. It is also extremely easy and quick to come up with and code the simplest, least efficient solution to these problems…

Here is the copy of Satoshi’s famous White Paper on bitcoin: Please read, understand, distribute, upload this paper on your website if you care about open and free internet.

Graph theory is immensely popular among interviewers in a variety of industries. Here is an interview problem on Graph Theory asked at Jane Street, a FinTech firm.

Feel free to take a look at some of our previous Graph Theory problems and their solutions.


Suppose you are given a table of currency exchange rates, represented as a 2D array. …

Dynamic programming is a favorite of many interviewers during programming interviews — it tests your problem formulation strategy, good use of recursive algorithms and data structures (mostly multi-dimensional arrays or hashtables), and also tests your ability to reason about computational complexity of a recursive algorithm with memoization.

Let’s work our way through a Dynamic Programming problem in an unexpected place. The problem was asked by QuantCast. Feel free to look through other posts for most instances of Dynamic Programming.


You are presented with an array representing a Boolean expression. The elements are of two kinds:

Determine the number of ways…

We are taking a break from data science, probability and statistics; and revisiting programming exercises. The problem we are going to tackle in this post comes from graph theory and efficient graph traversal. Graph theory is favorite of many interviewers, because formulating a problem in graph theory terms involves a lot of insight, and really tests a candidate’s skills. Most algorithms fit a few tens of lines of code, and whiteboard coding is a quick and easy way of testing those skills.

Read along for a fun application of graph traversal. The problem was asked by Uber. …

In previous post, we saw how to calculate expected values and conditional expectations of random variables. In this post, we are going to solve a tricky problem involving more expectations and correlations. The problem was asked by Robinhood.

Recall that some of the hardest data science interview questions involve conditional expectations. Even among them, correlations are the hardest to calculate! Read on to find out how to efficiently compute them.


Say you roll a fair dice 5 times. Let X be the number of times a 2 was rolled, and Y the number of times a 3 was rolled. …

Happy 2021 everyone! This year, we are bringing more solutions to common interview questions to you.

First up, we are continuing with a couple of data science questions, especially on expectations. Expected value of random variables (and their correlations) are some of the most common, and some of the hardest interview questions to crack. Follow along to see some techniques on solving them.

(Feel free to browse a few other posts on data science interview questions)

Problem 1 (Disney):

Alice and Bob are choosing their top 3 shows from a list of 50 shows. Assume that they choose independently of one another. Being…


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