Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import accumulate
- class NumArray:
- def __init__(self, nums: List[int]):
- self.dp = list(accumulate(nums))
- def sumRange(self, i: int, j: int) -> int:
- if i == 0:
- return self.dp[j]
- else:
- return self.dp[j] - ( self.dp[i-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement