From cd870938f6cf266292e0e5cecb2d96d604b2ad9d Mon Sep 17 00:00:00 2001 From: Gloria Mundi Date: Sun, 10 Mar 2024 20:48:51 +0100 Subject: make Fenwick Tree prefix sum exclusive --- datastructures/fenwickTree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'datastructures/fenwickTree.cpp') 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; } -- cgit v1.2.3