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

看板Marginalman作者 (franchouchouISBEST)時間1年前 (2024/06/06 20:04), 編輯推噓2(200)
留言2則, 2人參與, 1年前最新討論串324/1549 (看更多)
感覺應該還可以剪一些枝 懶剪了 def isNStraightHand(self, hand: List[int], groupSize: int) -> bool: cnt = defaultdict(int) for i in hand: cnt[i] += 1 sorted_keys = sorted(cnt.keys()) for k in sorted_keys: cnt_cur = cnt[k] if cnt_cur>0: for i in range(groupSize): if (k+i) in cnt.keys(): cnt[k+i] = cnt[k+i]-cnt_cur else: return False elif cnt_cur<0: return False return True -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.137.52.133 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1717675493.A.B5D.html

06/06 20:06, 1年前 , 1F
沒大引號 失敗
06/06 20:06, 1F

06/06 20:22, 1年前 , 2F
python又沒大引號
06/06 20:22, 2F
文章代碼(AID): #1cOQNbjT (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1cOQNbjT (Marginalman)