We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2463148 commit 0f09d77Copy full SHA for 0f09d77
C++/count-the-number-of-substrings-with-dominant-ones.cpp
@@ -19,7 +19,7 @@ class Solution {
19
}
20
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
21
for (int c = 0; c <= min(l, curr - 1); ++c) {
22
- if (((i - idxs[(curr - c) - 1]) - c) - c * c + 1 >= 1) {
+ if (c * c <= (i - idxs[(curr - c) - 1]) - c) {
23
result += min(min(idxs[curr - c], i) - idxs[(curr - c) - 1], ((i - idxs[(curr - c) - 1]) - c) - c * c + 1);
24
25
0 commit comments