RangeSum returns the sum of the elements in the range l to r both inclusive.
(l int, r int)
| 48 | // RangeSum returns the sum of the elements in the range l to r |
| 49 | // both inclusive. |
| 50 | func (f *FenwickTree) RangeSum(l int, r int) int { |
| 51 | return f.PrefixSum(r) - f.PrefixSum(l-1) |
| 52 | } |
| 53 | |
| 54 | // Add Adds value to the element at position pos of the array |
| 55 | // and recomputes the range sums. |