Code RoomComposite index seek
HardPrep Room Coding #345

Composite index seek

CodingDatabases & SQLSenior~30 min

A composite B-tree index is keyed on (region, score) and stores entries sorted by region ascending, then score ascending. Entries are given as [region, score, row_id], already in that sorted order. Implement an index seek for the query WHERE region = R AND score >= min_score, returning the row_ids of matching entries in index order. You must use the index ordering to seek — binary-search to the first matching entry rather than scanning all entries (assume the matching slice is small relative to the index). region is a string, score an int. Up to 200000 entries.

Implement
composite_index_seek(entries: list[list], region: str, min_score: int) → list[int]
Examples
in[[["east",10,1],["east",20,2],["west",5,3]],"east",15]out[2]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 30 min
InputExpectedGot
[[["east",10,1],["east",20,2],["west",5,3]],"east",15][2]not run yetsample