~/problems

Problems

Basics first, then the classics, then company-style assessments. Every problem has tests you run right here; multi-level ones unlock as you go. See the roadmap.

Stateful stores

Bank system

Accounts, transfers that must be accepted, merges; state machines.

Notes

Format: CodeSignal-style, 4 levels.

Strategy

  • An Account object with balance, outgoing and history.
  • Delayed effects (cashback): a heap of (due_time, seq, payment), drained at the top of every method.
  • Balance history: append (time, balance) on every change, and bisect it for "balance at time t".
  • Merges: move pointers (a payment's owner) instead of copying data around.

Gotchas: are failed operations counted? Is rounding down done with integer division? Is an effect due at time T applied before an operation at T?

3 problems

Practical systems

Stateful stores Key-value stores, file systems, banks, with history.

Bank system

esc