Code RoomBitmap index query
MediumPrep Room Coding #340

Bitmap index query

CodingDatabases & SQLMid–Senior~26 min

A bitmap index represents each predicate as a list of row positions (0-based) where the predicate is true, given as a SORTED list of ints. Evaluate a boolean query: given bitmaps `a`, `b`, `c` and an operator string, return the sorted list of matching row ids. Supported operators: 'and' = a AND b, 'or' = a OR b, 'and_not' = a AND NOT b, 'and_or' = a AND (b OR c). Each input bitmap is sorted with no duplicates. The result must be sorted ascending with no duplicates.

Implement
bitmap_query(a: list[int], b: list[int], c: list[int], op: str) → list[int]
Examples
in[[0,1,2,3],[2,3,4],[],"and"]out[2,3]
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 26 min
InputExpectedGot
[[0,1,2,3],[2,3,4],[],"and"][2,3]not run yetsample