Re: [閒聊] 每日leetcode

看板Marginalman作者 (通通打死)時間11月前 (2025/01/05 20:09), 編輯推噓0(002)
留言2則, 2人參與, 11月前最新討論串1246/1554 (看更多)
最近真的超懶刷 整個腦子變的鈍鈍的== 一二三四五 def shiftingLetters(self, s: str, shifts: List[List[int]]) -> str: tmp = [0 for _ in range(len(s))] for shft in shifts: if shft[2]==1: tmp[shft[0]] += 1 if shft[1]+1 < len(s): tmp[shft[1]+1] -= 1 else: tmp[shft[0]] -= 1 if shft[1]+1 < len(s): tmp[shft[1]+1] += 1 ans = "" cur_shft = 0 for i in range(len(s)): cur_shft += tmp[i] ans += chr(((ord(s[i])-ord('a')+cur_shft) % 26) + ord('a')) return ans -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1736078947.A.0A6.html

01/05 20:18, 11月前 , 1F
大師
01/05 20:18, 1F

01/05 20:30, 11月前 , 2F
大師
01/05 20:30, 2F
文章代碼(AID): #1dUdPZ2c (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1dUdPZ2c (Marginalman)