class NumArray(object):
def __init__(self, nums):
self.dp = nums
for i in xrange(1, len(nums)):
self.dp[i] += self.dp[i1]
def sumRange(self, i, j):
return self.dp[j]  (self.dp[i1] if i > 0 else 0)
A very short Python solution

@chris.zhang.336 I think if you dont' use "self.dp=nums[:]", you will change the nums.