Re: [閒聊] 每日leetcode

作者: DJYOMIYAHINA (通通打死)   2024-12-04 23:22:04
就greedy找下去
有找到相同or差一個的就先配對掉
寫醜醜
def canMakeSubsequence(self, str1: str, str2: str) -> bool:
i,j = 0,0
while i<len(str1):
if j>=len(str2):
break
if (ord(str2[j])-ord(str1[i]))==1 or (ord(str2[j])-ord(str1[i]))==0
or (ord(str2[j])-ord(str1[i]))==-25:
j += 1
i += 1
return j==len(str2)
作者: oin1104 (是oin的說)   2024-12-04 23:33:00
大師

Links booklink

Contact Us: admin [ a t ] ucptt.com