Code RoomRange minimum queries
MediumPrep Room Coding #1112

Range minimum queries

CodingDatabases & SQLAlgorithms & data structuresMid–Senior~30 min

Given a static integer array and a list of [l, r] queries, return the minimum of each inclusive range arr[l..r]. The array never changes but there can be up to 1e5 queries, so precompute a sparse table (table[k][i] = min of the 2^k elements starting at i) for O(1) per query via two overlapping power-of-two blocks. Return the list of range minima in query order.

Implement
sparse_table_rmq(arr: list[int], queries: list[list[int]]) → list[int]
Examples
in[[5,2,4,7,6,3,1,2],[[0,3],[2,5],[4,7],[6,6]]]out[2,3,1,1]
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
[[5,2,4,7,6,3,1,2],[[0,3],[2,5],[4,7],[6,6]]][2,3,1,1]not run yetsample