Interview Problems with Worked Solutions

Updated · By

18 coding problems, two for each common pattern, and 4 system design prompts, all from Devana's own question bank. Each page has the statement, hints you open one at a time, the approach from brute force to optimal with its complexity, tested solutions in Python and JavaScript, follow-up questions and common mistakes, and a button that starts the problem as a voice mock interview.

How to use these problems

  1. Try it cold. Read the statement, the constraints and the two examples, and give it ten minutes before opening anything.
  2. Open one hint at a time. Each hint gives away a little more. Stop as soon as you can see the way.
  3. Read the approach, then the code. The approach goes from the brute force to the answer worth giving, with the time and space of each, and how to say it in the interview.
  4. Say it out loud. Each page opens its problem as a voice mock interview, where you explain it to an interviewer who asks the follow-ups.

Arrays and hashing

Trade memory for speed with a constant-time lookup. The guide: arrays and hashing.

Two pointers

Two indexes moving through sorted data, each step ruling something out. The guide: two pointers.

Sliding window

A range that grows at one end and shrinks at the other, here measured in time. The guide: sliding window.

Stack

The most recent open thing is the one that has to close first. The guide: stack.

Halving a sorted space to find a boundary in O(log n). The guide: binary search.

Trees and tries

Hierarchies where the answer flows down from the root. The guides: trees and tries.

Graphs

Dependencies and connections, searched breadth-first or ordered topologically. The guide: graphs.

Heaps

The best k of many without sorting all of them. The guide: heaps.

Dynamic programming

A table of answers to smaller versions of the problem. The guide: 2-D dynamic programming.

System design

Open-ended designs, worked from requirements to trade-offs. The guides: choosing and modeling a database, caching, message queues and async work and sharding and replication.

About these problems

Every problem here is one of Devana's own questions. Each page names the company-style set the question sits in, such as Netflix or Stripe; none of them is a question leaked from that company, and Devana is not affiliated with any of them. Well-known problems from public problem sites are not included.

The solutions are tested: both versions of every solution run against the same cases, including each page's examples, before the pages are published. The question bank has many more questions to practice, by company, topic and round.

Try a mock interview free

3 interviews a month on the Free plan, up to 20 minutes each. No card needed.