2023-09-12 11:07:17 +0000 UTC
Range Sum Query - Immutable
Categories:
Links
Code
class NumArray:
def __init__(self, nums: List[int]):
self._nums = nums
def sumRange(self, left: int, right: int) -> int:
return sum(self._nums[left:right+1])
# Your NumArray object will be instantiated and called as such:
# obj = NumArray(nums)
# param_1 = obj.sumRange(left,right)