Skip to content

Commit 6fba85f

Browse files
authored
Update bold-words-in-string.cpp
1 parent cf5eeab commit 6fba85f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

C++/bold-words-in-string.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Solution {
1212
vector<bool> lookup(S.length());
1313
for (int i = 0; i < S.length(); ++i) {
1414
auto curr = &trie;
15-
int k = -1;
15+
int k = i - 1;
1616
for (int j = i; j < S.length(); ++j) {
1717
if (!curr->leaves[S[j] - 'a']) {
1818
break;
@@ -22,9 +22,7 @@ class Solution {
2222
k = j;
2323
}
2424
}
25-
for (int j = i; j <= k; ++j) {
26-
lookup[j] = true;
27-
}
25+
fill(lookup.begin() + i, lookup.begin() + k + 1, true);
2826
}
2927

3028
string result;

0 commit comments

Comments
 (0)