We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent de86f4b commit c5330eaCopy full SHA for c5330ea
1 file changed
src/data-structures/BinaryIndexedTree.java
@@ -21,15 +21,15 @@ private void constructBIT(int[] nums) {
21
}
22
23
public void update(int i, int delta) {
24
- int k = i;
+ int k = i + 1;
25
while (k <= this.N) {
26
this.tree[k] += delta;
27
k += lowBit(k);
28
29
30
31
public int query(int i) {
32
33
int res = 0;
34
while (k > 0) {
35
res += this.tree[k];
0 commit comments