diff options
| author | Gloria Mundi <gloria@gloria-mundi.eu> | 2024-03-10 20:48:51 +0100 |
|---|---|---|
| committer | Gloria Mundi <gloria@gloria-mundi.eu> | 2024-03-10 20:48:51 +0100 |
| commit | cd870938f6cf266292e0e5cecb2d96d604b2ad9d (patch) | |
| tree | a1615ad3cac2c505c33e9952fc72cced5931d6c9 /datastructures/fenwickTree.cpp | |
| parent | 0cebc901e79c21168601071e29ed8e4f4b6f9505 (diff) | |
make Fenwick Tree prefix sum exclusive
Diffstat (limited to 'datastructures/fenwickTree.cpp')
| -rw-r--r-- | datastructures/fenwickTree.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/datastructures/fenwickTree.cpp b/datastructures/fenwickTree.cpp index cac3cf8..6c5ed91 100644 --- a/datastructures/fenwickTree.cpp +++ b/datastructures/fenwickTree.cpp @@ -10,6 +10,6 @@ void init(int n) { ll prefix_sum(int i) { ll sum = 0; - for (i++; i > 0; i -= (i & (-i))) sum += tree[i]; + for (; i > 0; i -= (i & (-i))) sum += tree[i]; return sum; } |
