Skip to content

Commit

Permalink
Q303 added.
Browse files Browse the repository at this point in the history
  • Loading branch information
isinsuarici committed Mar 17, 2023
1 parent 43db3eb commit 5398219
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions E_303_RangeSumQueryImmutable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class NumArray {
int[] arr;
public NumArray(int[] nums) {
this.arr=new int[nums.length+1];
for(int i=1;i<arr.length;i++){
arr[i]=arr[i-1]+nums[i-1];
}
}

public int sumRange(int left, int right) {
return arr[right+1]-arr[left];
}
}

0 comments on commit 5398219

Please sign in to comment.