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:
The array is only modifiable by the update function.
You may assume the number of calls to update and sumRange function is distributed evenly.
提示:提交代碼後,需要用簡潔的語言解釋一下代碼思路~ 謝謝
歷史題目和總結見公眾號「每日一道算法題」
https://leetcode.com/problems/range-sum-query-mutable/description/
[每日一題 - 小Fu講解] 307. Range Sum Query - Mutable
https://www.bilibili.com/video/av15683671/
https://youtu.be/S0Bf9jpgHmQ