Skip to content

Commit 0f09d77

Browse files
authored
Update count-the-number-of-substrings-with-dominant-ones.cpp
1 parent 2463148 commit 0f09d77

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

C++/count-the-number-of-substrings-with-dominant-ones.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Solution {
1919
}
2020
const int l = (-1 + sqrt(1 + 4 * (i + 1))) / 2; // since c^2 <= (i+1)-c, thus c <= (-1+(1+4*(i+1))**0.5)/2
2121
for (int c = 0; c <= min(l, curr - 1); ++c) {
22-
if (((i - idxs[(curr - c) - 1]) - c) - c * c + 1 >= 1) {
22+
if (c * c <= (i - idxs[(curr - c) - 1]) - c) {
2323
result += min(min(idxs[curr - c], i) - idxs[(curr - c) - 1], ((i - idxs[(curr - c) - 1]) - c) - c * c + 1);
2424
}
2525
}

0 commit comments

Comments
 (0)