In-Memory Query Engine is a small service for searching transaction records. You give it a filter, such as "settled payments for acct-1 of at least $25.00", and it returns the matching records, newest first.
The starting code handles a single filter correctly, but breaks as soon as you combine two.
The round has five phases:
insert and delete while keeping pages correct as records change underneath them.Each phase builds on the previous one, so the decisions you make early on matter.
In Phase 1, fixing the sort gives every record an exact position based on (createdAt, id). That exact position is what makes the Phase 2 cursor correct.
If the Phase 2 cursor is a real keyset cursor (one that remembers the last key returned, not a row count), Phase 3 needs almost no work in query(). Phase 4 then comes down to a binary search over that same key.
A candidate who gets the ordering key right early finds every later phase smaller. One who gets it slightly wrong keeps paying for it.