https://leetcode.com/problems/range-sum-query-immutable/
class NumArray {
static int[] nums;
public NumArray(int[] nums) {
this.nums = nums;
}
public int sumRange(int i, int j) {
if (i == j)
return nums[i];
if (i +1 == j)
return nums[i] + nums[j];
return nums[i] + sumRange(i+1 , j-1) + nums[j];
}
}
/**
* Your NumArray object will be instantiated and called as such:
* NumArray obj = new NumArray(nums);
* int param_1 = obj.sumRange(i,j);
*/