Range minimum queries
Given a static integer array arr and a list of inclusive range queries [l, r] (0-indexed, l <= r), return the minimum element of each range. Build a segment tree so each query is O(log n). Values may be negative. Return the list of minima in query order.
Implement
range_min_queries(arr: list[int], queries: list[list[int]]) → list[int]Examples
in
[[2,5,1,4,9,3],[[0,5],[1,3],[4,4],[3,5]]]out[1,1,9,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 25 min
solution.py
InputExpectedGot
[[2,5,1,4,9,3],[[0,5],[1,3],[4,4],[3,5]]][1,1,9,3]not run yetsample