aboutsummaryrefslogtreecommitdiff
path: root/Data Structures
diff options
context:
space:
mode:
authorAnthony Wang2020-07-17 23:06:42 -0500
committerAnthony Wang2020-07-17 23:06:42 -0500
commit72a56cbea444a9c600fca6de0430b6bd25f24435 (patch)
tree3d55622a7230c1832748da2c386787cbd0d80315 /Data Structures
parentc7bf1734730ba95155a30457d735e4a0282e68a3 (diff)
Update fenwick_tree.cpp
Diffstat (limited to 'Data Structures')
-rw-r--r--Data Structures/fenwick_tree.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Data Structures/fenwick_tree.cpp b/Data Structures/fenwick_tree.cpp
index 19120ab..ba75c58 100644
--- a/Data Structures/fenwick_tree.cpp
+++ b/Data Structures/fenwick_tree.cpp
@@ -3,6 +3,6 @@ private: vector<T> FT;
public:
fenwick_tree(int N) { FT.assign(N + 5, 0); }
void update(int x, T val) { if (++x) for (; x < FT.size(); x += x & -x) FT[x] += val; }
- T query(int x) { T ret = 0; if (++x) for (; x > 0; x -= x & -x) ret += FT[x]; return ret; }
+ T query(int x) { T ret = 0; if (++x) for (; x; x -= x & -x) ret += FT[x]; return ret; }
T query(int x, int y) { return query(y) - query(x - 1); }
}; \ No newline at end of file