diff options
author | Anthony Wang | 2021-12-12 16:03:41 +0000 |
---|---|---|
committer | GitHub | 2021-12-12 16:03:41 +0000 |
commit | c565f3fb7179e285b89a7df0232bede429833a16 (patch) | |
tree | 26b77806987c2cc2e4f1e0e4e22a58d88a2593b5 | |
parent | 924653b7cd41d61bbe973434f0b972f3d5e8f75f (diff) | |
parent | 7761f38957fecd5f45bc62d55e9a77636a2b11d5 (diff) |
Merge pull request #4 from dush1729/patch-1
fix off by one in sparse table
-rw-r--r-- | Data Structures/sparse_table.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Data Structures/sparse_table.cpp b/Data Structures/sparse_table.cpp index c303930..841674e 100644 --- a/Data Structures/sparse_table.cpp +++ b/Data Structures/sparse_table.cpp @@ -8,7 +8,7 @@ public: for (int i = 0; i <= log(N); i++) st[i].resize(N); for (int i = 0; i < N; i++) st[0][i] = A[i]; for (int i = 1; i <= log(N); i++) { - for (int j = 0; j + (1 << i) < N; j++) st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]); + for (int j = 0; j + (1 << i) <= N; j++) st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]); } } |