| 6 | #define mod 1000000007 |
| 7 | #define endl '\n' |
| 8 | string compressString(string s){ |
| 9 | int n=s.length(); |
| 10 | string ans; |
| 11 | for (int i = 0; i < n; i++) { |
| 12 | int count=1; |
| 13 | while(s[i]==s[i+1] && i<n-1){ |
| 14 | count++; |
| 15 | i++; |
| 16 | } |
| 17 | ans+=s[i]; |
| 18 | ans+=to_string(count); |
| 19 | } |
| 20 | if(ans.length()<s.length()) |
| 21 | return ans; |
| 22 | else |
| 23 | return s; |
| 24 | |
| 25 | } |
| 26 | int main(){ |
| 27 | cin.tie(0)->sync_with_stdio(0); |
| 28 | string s1 ="aaabbccddee"; |