Re: [闲聊] 每日leetcode

楼主: JerryChungYC (JerryChung)   2024-11-02 03:26:46
※ 引述《DJYOMIYAHINA (通通打死)》之铭言:
: 其实
: 蛮男的
: 写了很久
: 我就这样了
: 一二三四五
这题是easy 所以你要照直觉写
Python Code:
class Solution:
def makeFancyString(self, s: str) -> str:
for word in set(s):
while word * 3 in s:
s = s.replace(word * 3, word * 2)
return s
楼主: JerryChungYC (JerryChung)   2024-11-02 03:27:00
4个a把3个取代会变成3个 所以用while
作者: sustainer123 (caster)   2024-11-02 08:45:00
大神
作者: DJYOMIYAHINA (通通打死)   2024-11-02 09:33:00
技术大牛==

Links booklink

Contact Us: admin [ a t ] ucptt.com