nums从0开始
sum从1开始
left和right从0开始
class NumArray {
int[] sum;
public NumArray(int[] nums) {
sum = new int[nums.length+1];
for(int i = 1;i<=nums.length;i++){
sum[i] = nums[i-1]+sum[i-1];
}
}
public int sumRange(int left, int right) {
return sum[right+1]-sum[left];
}
}