303 Range Sum Query - Immutable
Last updated
Was this helpful?
Last updated
Was this helpful?
Given an integer arraynums, find the sum of the elements between indicesiandj(i≤j), inclusive.
Example:
Note:
You may assume that the array does not change.
There are many calls to sumRange function.
(1) DP
DP: 时间复杂度: NumArray(): O(n), sumRange(): O(1), 空间复杂度O(n)