Skip to content

Commit d5a04a4

Browse files
authored
Update find-longest-special-substring-that-occurs-thrice-i.cpp
1 parent fd4d376 commit d5a04a4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

C++/find-longest-special-substring-that-occurs-thrice-i.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ class Solution2 {
3434
vector<vector<int>> lookup(26, vector<int>(1));
3535
int result = 0;
3636
for (int i = 0; i < size(s); ++i) {
37-
const int x = s[i] - 'a';
37+
auto& curr = lookup[s[i] - 'a'];
3838
for (int j = i; j < size(s); ++j) {
3939
if (s[j] != s[i]) {
4040
break;
4141
}
4242
const int l = j - i + 1;
43-
if (l == size(lookup[x])) {
44-
lookup[x].emplace_back();
43+
if (l == size(curr)) {
44+
curr.emplace_back();
4545
}
46-
if (++lookup[x][l] == 3) {
46+
if (++curr[l] == 3) {
4747
result = max(result, l);
4848
}
4949
}

0 commit comments

Comments
 (0)