Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 1.67 KB

File metadata and controls

41 lines (30 loc) · 1.67 KB

< Previous                  Next >

Given an integer array nums, find the sum of the elements between indices i and j (ij), inclusive.

The update(i, val) function modifies nums by updating the element at index i to val.

Example:

Given nums = [1, 3, 5]

sumRange(0, 2) -> 9
update(1, 2)
sumRange(0, 2) -> 8

Note:

  1. The array is only modifiable by the update function.
  2. You may assume the number of calls to update and sumRange function is distributed evenly.

Related Topics

[Binary Indexed Tree] [Segment Tree]

Similar Questions

  1. Range Sum Query - Immutable (Easy)
  2. Range Sum Query 2D - Mutable (Hard)