作者DJYOMIYAHINA (通通打死)
看板Marginalman
標題Re: [閒聊] 每日leetcode
時間Sun Feb 2 22:28:30 2025
過完年連綠色題目都不會了...
我好想那個
def check(self, nums: List[int]) -> bool:
pre = nums[-1]
fail_cnt = 0
for i in range(len(nums)):
if nums[i]<pre:
fail_cnt += 1
if fail_cnt >= 2:
return False
pre = nums[i]
return True
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1738506512.A.E4A.html
→ Rushia: 大師 02/02 22:32
→ DJYOMIYAHINA: 一開始pre忘記設成nums[-1] 搞了好久== 02/02 22:32