constructor(length) {
    this._size = length;
    this._elementsSum = new Array(length * 2);
    this._elementsMin = new Array(length * 2);
    this._elementsMax = new Array(length * 2);

    for (let i = 0; i < this._size; i++) {
      this._elementsSum[i] = 0;
      this._elementsMin[i] = 0;
      this._elementsMax[i] = 0;
    }
  }
Segment Tree

Segment Tree helps to perform various function over a range efficiently
in O(log n) time.

In addition to functions that can be implemented by Fenwick Tree,
Segment Tree can even perform functions such as minimum or maximum
over a range, which cannot be answered by Fenwick Tree.

More complicated functions can be done in logarithmic time by doing
lazy modification, however the implementation depends on type of function
and hence is not implemented here.

Segment Tree is similiar to binary tree. The element value is stored in
leaf nodes and value of function from range[l,r] is stored in internal nodes.

The root node i.e. index 1 stores the value by performing function over
entire range. Similarly other index stores value by performing function
in range of its subtree.