精華區beta Marginalman 關於我們 聯絡資訊
就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) -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1733325726.A.9C8.html
oin1104: 大師 12/04 23:33