We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d449a3b commit 66d1104Copy full SHA for 66d1104
3163. String Compression III
@@ -0,0 +1,27 @@
1
+class Solution {
2
+public:
3
+ string compressedString(string word)
4
+ {
5
+ string ans;
6
+
7
+ int count = 0;
8
+ char prev = word[0];
9
+ for(auto ch : word)
10
11
+ if(prev != ch or count == 9)
12
13
+ ans += to_string(count);
14
+ ans += prev;
15
+ prev = ch;
16
+ count = 0;
17
+ }
18
+ count += 1;
19
20
+ if(count)
21
22
23
24
25
+ return ans;
26
27
+};
0 commit comments