作者DJYOSHITAKA (franchouchouISBEST)
看板Marginalman
標題Re: [閒聊] 每日leetcode
時間Thu May 30 00:41:48 2024
我也不知道我在寫什麼
明明簡單記進位就好了
def numSteps(self, s: str) -> int:
cnt = 0
i = len(s)-1
while s[i] == '0':
cnt += 1
i -= 1
last = i
for j in range(i, -1, -1):
if s[j] == '0':
cnt += (last-j+1)
last = j
if last != 0:
cnt += (last+2)
return cnt
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.79.34.96 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1717000910.A.71D.html
推 JIWP: 別卷了 05/30 00:44
推 oin1104: 又在捲 05/30 00:46
→ rainkaras: 我都不敢發我寫的題目了 05/30 00:58
→ sustainer123: 發啊 05/30 01:02
→ sustainer123: 那有差 05/30 01:02