InterviewLegend

Design & Data Structures

Alex Chen24 min readUpdated 138 real interview reports

Design problems hand you an interface and a complexity target, usually O(1), and ask you to build the class behind it. A Premium question is one of Amazon's three most-asked coding questions. (LRU is short for least-recently-used: a fixed-size store that evicts whatever you touched longest ago.) Know it cold. Amazon rarely states it as the textbook puzzle, though. They wrap it in a product story: track a customer's recently viewed items, cap the history, keep lookups instant.

Every one of these is the same move. Compose two data structures so each operation lands on its required speed. Almost always the pairing is a hash map plus one more structure. A map gives instant lookup and little else. So you bolt on whatever covers the operation it cannot do: a linked list for recency, a heap for the largest few. The workflow is mechanical. List the operations. Mark the speed each one needs, then pick the partner structure that fills the gap.

What's inside
  • 2 problems, worked step by step
  • 4 diagrams
  • about 24 min

Premium lessonAmazon interview guide

These took digging.

What candidates walked out with, from 20,000+ reports, forum threads behind logins and write-ups in Chinese. Then solved step by step.

100 companies. Checked every month.

Unlock all 100 companies

$49 a year · less than $1 a week · Cancel anytime

Had your Amazon interview?Tell us what they asked. Reviewed before it goes in, never with your name.
Amazon interview guide

Know what Amazon asks before you walk in.

19 coding · 6 system design · 44 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.