Every case study in five lines
Each of the 27 case studies on this site is a 45-minute mock interview of about eleven pages. This page gives each one in five lines, so that in the week before a round you can recall the shape of every question without rereading it. The five lines are always the same. The ask is what the interviewer wants, the other names the question goes by, and the count that sets its size. The design is the main classes in the order a call reaches them, in one sentence. The patterns are the patterns the page uses, each with the simpler design it beat. The deep dives are that page's two Step 6 deep dives in order, with the page each one applies. The trap is the mistake from that page's "Mistakes that cost offers" that most candidates make.
Every figure is copied from the case study's own 2-minute answer or cheat sheet, and each heading links that page. Read all 27 once, and mark the ones closest to what your company asks (How the round differs by company). Then reread those in full.
Case studies: the classics
Parking lot
- The ask. Design the software for a parking lot with several levels, also asked as "design a parking garage". The lot has 5,000 spots.
- The design.
ParkingLot.parkchecks at most 10 free stacks on theLevels, occupies aSpotand writes aTicket. - The patterns. Strategy, as a list of fee rules the lot adds up, beat an
ifper rule insideparkandleave. - The deep dives. Electric charging spots, then two cars, one spot. They apply Open/closed and Check-then-act.
- The trap. Do not lock the check but not the act, or make each collection thread-safe on its own.
Elevator system
- The ask. Design the software for the elevators in a building, with buttons on every floor, also asked as "design a lift system". The building has 4 cars.
- The design. One dispatcher thread asks a
DispatchRulefor eachCall, and eachElevatorkeeps two sets of stops. - The patterns. State, one class per state, beat a table of moves, since 5 of 9 answers do work. Strategy, for the dispatch rule, beat an
ifper rule. - The deep dives. A new dispatch rule, then a press as a car falls asleep. They apply Strategy and Producer–consumer.
- The trap. Do not look at the stops and sleep as two steps, because a press then wakes nobody.