Skip to content

Commit a3f0cde

Browse files
committed
3163
1 parent 625cd3d commit a3f0cde

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Nov-4-24.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def compressedString(self, word: str) -> str:
3+
comp = ""
4+
freq = 1
5+
for i in range(1,len(word)):
6+
if freq==9 or word[i]!=word[i-1]:
7+
comp += str(freq)+word[i-1]
8+
freq = 1
9+
else:
10+
freq += 1
11+
comp += str(freq)+word[-1]
12+
return comp

0 commit comments

Comments
 (0)