2019-04-16 吴亲库里 库里的深夜食堂
给定一个整型数组,指定的区间让你求区间之间和的值,我这里实现的时间复杂度是O(n),空间复杂度也是O(n),这里可以优化的是空间复杂度

class NumArray {
/**
* @param Integer[] $nums
*/
private $nums;
function __construct($nums) {
$this->nums=$nums;
}
/**
* @param Integer $i
* @param Integer $j
* @return Integer
*/
function sumRange($i, $j) {
while($i<=$j){
$res +=$this->nums[$i];
$i++;
}
return $res;
}
}
/**
* Your NumArray object will be instantiated and called as such:
* $obj = NumArray($nums);
* $ret_1 = $obj->sumRange($i, $j);
*/
