Interview classics
The questions interviewers actually ask, with the part they are really testing made explicit. Each one has an answer anyone finds in a minute and a better one that needs you to spot the repeated work, and the grader holds you to the better one.
—Exercises
8 exercises
Brackets that close in the right order
a list as a stack, matching pairs
~20 min
The best day to buy and the best day to sell
running minimum, one pass
~20 min
The first letter that appears only once
count first, then look, Counter
~15 min
The one ticket number nobody handed in
the sum you expect, arithmetic instead of searching
~15 min
Two numbers that add up to a target
dict as a lookup, one pass
~20 min
The best run of consecutive days
Kadane’s algorithm, extend or start again
~25 min
The longest stretch with no letter repeated
sliding window, last seen position
~30 min
Merge the meetings that overlap
sort first, compare with the last kept
~25 min