es-next-tools
Version:
A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.
23 lines (22 loc) • 662 B
TypeScript
/**
* Represents a segment tree for range queries.
*/
export declare class SegmentTree {
private tree;
private n;
constructor(data: number[]);
private build;
/**
* Updates a value in the segment tree.
* @param {number} index - The index to update.
* @param {number} value - The new value.
*/
update(index: number, value: number): void;
/**
* Queries the sum in a range [left, right).
* @param {number} left - The left index (inclusive).
* @param {number} right - The right index (exclusive).
* @returns {number} The sum in the range.
*/
query(left: number, right: number): number;
}