作者Meaverzt (Meaverzt)
標題Re: [閒聊] 每日leetcode
時間2024-11-05 02:26:16
def compressedString(self,word):
ans=[]
num=1
for i in range(len(word)):
if i<len(word)-1 and word[i]==word[i+1] and num<9:
num=num+1
else:
ans.append(str(num))
ans.append(word[i])
num=1
return ''.join(ans)
都修完程設一二跟python了
還寫成這一坨答辯
這輩子我就這樣了
----
Sent from
BePTT on my Samsung SM-S9210
--
※ 發信站: 批踢踢實業坊(ptt-website.tw), 來自: 101.136.50.83 (臺灣)
※ 文章網址: https://ptt-website.tw/Marginalman/M.1730744778.A.B37