3163. String Compression III
## 思路
照題目作
記錄前一個字母跟累計個數
## Code
```python
class Solution:
def compressedString(self, word: str) -> str:
res = []
cnt = 0
prev = word[0]
for ch in word:
if ch != prev:
res.append(f'{cnt}{prev}')
cnt, prev = 1, ch
elif cnt == 9:
res.append(f'{cnt}{ch}')
cnt = 1
else:
cnt += 1
res.append(f'{cnt}{ch}')
return ''.join(res)
```