Range Minimum Query (Dynamic)
Range Minimum Query (Dynamic)
You are given an array nums and a list of queries. Each query is one of:
[0, index, value]→ updatenums[index] = value[1, left, right]→ return the minimum value innums[left..right]
Return the results of all type-1 queries in order.
Function signature
func RangeMinQuery(nums []int, queries [][]int) []int
Example
nums = [5,2,6,3]
queries = [[1,0,2],[0,1,4],[1,1,3],[1,0,3]]
output = [2,3,3]
Constraints
- 0 <= len(nums) <= 200_000
- 0 <= len(queries) <= 200_000
- 0 <= index, left, right < len(nums)
- left <= right
- -1_000_000_000 <= value <= 1_000_000_000
Notes
- A segment tree supports updates and range minimum queries in O(log n).
Run tests to see results
No issues detected