public class NumArray {
int[] nums = null;
public NumArray(int[] nums) {
this.nums = nums;
}
public int sumRange(int i, int j) {
if(i < 0 || j >= nums.length){
return 0;
}
else{
int sum = 0;
for(int k = i; k <= j; k++){
sum += nums[k];
}
return sum;
}
}
}
/**
* Your NumArray object will be instantiated and called as such:
* NumArray obj = new NumArray(nums);
* int param_1 = obj.sumRange(i,j);
*/