303. 区域和检索
js
;(function(){
/**
* 303. 区域和检索 - 数组不可变
*
*/
class NumArray {
[prop: string]: any
constructor(nums: number[]) {
this.nums = nums
}
sumRange(left: number, right: number): number {
let total: number = 0
for(let i = left; i <= right; i++) {
total += this.nums[i]
}
return total
}
}
})()