Re: [閒聊] 每日leetcode已回收

看板Marginalman作者 (通通打死)時間1年前 (2024/07/05 08:46), 編輯推噓2(201)
留言3則, 3人參與, 1年前最新討論串446/1554 (看更多)
寫出一坨大便 對不起對不起對不起 早上拉屎應該很正常吧:( def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]: first_idx, last_idx,idx = 10**6,-1,0 mindis = 10**6 pre_idx = -1 pre_val = -1 while head is not None: if pre_val != -1 and head.next is not None: if (pre_val<head.val and head.next.val<head.val) or (pre_val>head.val and head.next.val>head.val): first_idx = min(first_idx, idx) last_idx = max(last_idx, idx) mindis = 10**6 if pre_idx == -1 else min(idx-pre_idx, mindis) pre_idx = idx pre_val = head.val head = head.next idx += 1 return [-1 if mindis == 10**6 else mindis, -1 if first_idx==10**6 and last_idx==-1 or first_idx==last_idx else last_idx-first_idx] -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1720140383.A.D16.html

07/05 08:49, 1年前 , 1F
太早了吧
07/05 08:49, 1F

07/05 09:04, 1年前 , 2F
寶 你還有在上班嗎
07/05 09:04, 2F

07/05 09:08, 1年前 , 3F
ㄉㄕ
07/05 09:08, 3F
文章代碼(AID): #1cXq9VqM (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1cXq9VqM (Marginalman)