303 Range Sum Query - Immutable
1. Question
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.
2. Implementation
(1) DP
3. Time & Space Complexity
DP: 时间复杂度: NumArray(): O(n), sumRange(): O(1), 空间复杂度O(n)
Last updated