Static Range Minimum — Solution & Editorial
Sparse table: precompute minima of every power-of-two window; a query is the min of two overlapping windows covering [L, R]. Idempotence of min makes the overlap harmless.
Complexity: O(N log N) build, O(1) per query