1d-range-query 中文文档教程
1d-range-query
高效范围最大/最小查询。
npm install 1d-range-query
Usage
import rangeQuery from '1d-range-query';
const query = rangeQuery([1,5,10,2,5,3]);
console.log(query.max(0, 2)); // => 10 (10 is the max in [1,5,10])
console.log(query.min(2, 4)); // => 2 (2 is the min in [10,2,5])
#query.max(from, to)
查询 [from, to]
范围内的最大值。
#query.min(from, to)
查询 [from, to]
范围内的最小值。
Complexity
Time
初始化:O(nlogn)
查询:O(1)
Space
O(nlogn)
License
MIT
1d-range-query
Efficient range maximum/minimum query.
npm install 1d-range-query
Usage
import rangeQuery from '1d-range-query';
const query = rangeQuery([1,5,10,2,5,3]);
console.log(query.max(0, 2)); // => 10 (10 is the max in [1,5,10])
console.log(query.min(2, 4)); // => 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
更多