Index intersection merge

Write codeHard30 minOracle and Google style

Your task

A planner can answer a multi-column AND predicate by intersecting two single-column indexes (index intersection / bitmap AND). You are given two posting lists, each a sorted list of unique int row_ids that match one predicate. Return the sorted list of row_ids present in BOTH lists (the AND result). Do this with a single linear merge of the two sorted lists (no set construction is required, though correctness is what is checked). Lists may be large (up to 1e5 each) and may be empty.

Examples

index_intersect(a: list[int], b: list[int]) -> list[int]
Example 1
Inputindex_intersect([1, 3, 5, 7, 9], [3, 4, 5, 6, 9])
Output[3, 5, 9]