1d-range-query
Efficient range maximum/minimum query.
npm install 1d-range-query
Usage
;const query = ;console; // => 10 (10 is the max in [1,5,10])console; // => 2 (2 is the min in [10,2,5])
#query.max(from, to)
Query the maximum value in range [from, to]
.
#query.min(from, to)
Query the minimum value in range [from, to]
.
Complexity
Time
Initialize: O(nlogn)
Query: O(1)
Space
O(nlogn)
License
MIT