Glad I invested in your site—it clearly paid off immensely. You're offering a unique style of practice I couldn't find anywhere else. Keep doing what you're doing.

Lexi got the job at Facebook:

Interview Cake taught me how to approach new problems. The questions helped me feel confident and ready to crush my coding interviews.

Chris got the job at Palantir:

I used a number of resources to help prep for the coding interviews but Interview Cake stood out as by far and away the most useful. I owe you a massive debt of thanks.

Cody got the job at Amazon:

Your practice problems boosted my confidence and helped me to think critically throughout the process. And I got the job! Just wanted to say thanks.

Chris got the job at Apple:

I got the job! Your questions prepared me big time and I felt really relaxed throughout the entire process. I believe in Interview Cake!

Mark got the job at Google:

Your problems were great practice and were definitely the sort of problems that I saw in my interviews. Thanks!

Abhijeet got the job at Amazon:

Thanks again for everything, Parker. Interview Cake really prepared me to land the offer.

Zafir got the job at Google:

Especially if you're on a time crunch, Interview Cake is well worth investing in for those crucial few weeks before your big interview. Thanks Parker!

Zak got the job at Mixpanel:

I got offers from 7/8 of the companies at which I interviewed. After not going through a formal interview process in nearly a decade, your site really helped build my confidence. You’re a hero, Parker ;)

Sample Question

Writing interview questions hasn't made me rich. Maybe trading Apple stocks will.

I have an array stock_prices_yesterday where:

The indices are the time, as a number of minutes past trade opening time, which was 9:30am local time.

The values are the price of Apple stock at that time, in dollars.

For example, the stock cost $500 at 10:30am, so stock_prices_yesterday[60] = 500.

Write an efficient algorithm for computing the best profit I could have made from 1 purchase and 1 sale of 1 Apple stock yesterday. For this problem, we won't allow "shorting"—you must buy before you sell.

It is not sufficient to simply take the difference between the highest price and the lowest price, because the highest price may come before the lowest price. You must buy before you sell.

You can do this in time.

The brute force approach would be to try every pair of times (treating the earlier time as the buy time and the later time as the sell time) and see which one is best. There are n^2 such combinations, so this will take time. We can do better.

If we're going to do better than , we're probably going to do it in either or . comes up in sorting and searching algorithms where we're recursively cutting the set in half. It's not obvious that we can save time by cutting the set in half here. Let's first see how well we can do by looping through the set only once (this costs only time).

Since we're going to loop through the set only once, let's use a greedy approach, where we keep a running max_profit until we reach the end. We'll start our max profit at $0. As we're iterating, how do we know if we've found a new max profit?

At each iteration, our max_profit is either:

the same as the max_profit at the last time step, or

the best profit we can get by selling at the current_price

How do we know when we have case (2)?

The best profit we can get by selling at the current_price is simply the difference between the current_price and the min_price to the left of it. If this difference is greater than the current max_profit, we have a new max_profit.

We walk through the array from beginning to end, keeping track of:

our min_price so far

our max_profit so far

For each time, we check to see if:

we have a new min_price, or

buying at the current min_price and selling at the current_price would give a new max_profit.