Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Files

Latest commit

d3d5118 · Jul 9, 2019

History

History
executable file
·
22 lines (14 loc) · 550 Bytes

File metadata and controls

executable file
·
22 lines (14 loc) · 550 Bytes

题目

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), 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.