Skip to content

Commit 97fc31e

Browse files
authored
Update rearrange-spaces-between-words.cpp
1 parent 901a363 commit 97fc31e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

C++/rearrange-spaces-between-words.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Solution {
2323
has_word = true;
2424
}
2525
if (has_word) {
26-
++left;
26+
++left; // keep one space
2727
}
2828
}
2929
// rearrange the spaces to the left
@@ -37,7 +37,7 @@ class Solution {
3737
has_word = true;
3838
}
3939
if (has_word) {
40-
right -= equal_count;
40+
right -= equal_count; // keep equal_count spaces
4141
}
4242
}
4343
return text;

0 commit comments

Comments
 (0)