Skip to content

Commit c656319

Browse files
committed
Time: 12 ms (23.31%), Space: 9 MB (67.76%) - LeetHub
1 parent 8af6b3e commit c656319

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Diff for: 443-string-compression/443-string-compression.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ class Solution {
55
int n = chars.size();
66
while(i<n){
77
int j = i+1;
8-
while(j<n && chars[i] == chars[j]){
9-
j+=1;
10-
}
8+
while(j<n && chars[i] == chars[j]) j+=1;
9+
1110

1211
// ya toh vector pura traverse krr diyaa
1312
// ya fir new/Different character encounter kia hai
@@ -17,9 +16,8 @@ class Solution {
1716
if(count > 1){
1817
// converting counting into single digit and saving in answer
1918
string cnt = to_string(count);
20-
for(char ch: cnt){
21-
chars[ansIndex++] = ch;
22-
}
19+
for(char ch: cnt) chars[ansIndex++] = ch;
20+
2321
}
2422
i = j;
2523
}

0 commit comments

Comments
 (0)