Re: [閒聊] 每日leetcode

看板Marginalman作者 (通通打死)時間1年前 (2024/09/05 09:12), 編輯推噓2(200)
留言2則, 2人參與, 1年前最新討論串811/1548 (看更多)
有一大坨比我快十倍的不知道怎麼用的== 但我看答案都差不多ㄚ 還是有改測資 def missingRolls(self, rolls: List[int], mean: int, n: int) -> List[int]: m = len(rolls) summation = mean*(n+m) sum_n = summation - sum(rolls) if sum_n<n or sum_n>6*n: return [] res = sum_n-(sum_n//n)*n ans = [(sum_n//n)+1] * res + [(sum_n//n)] * (n-res) return ans -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1725498741.A.B5A.html

09/05 09:22, 1年前 , 1F
你寫的好簡潔 我就這樣了
09/05 09:22, 1F

09/05 09:25, 1年前 , 2F
大師
09/05 09:25, 2F
文章代碼(AID): #1csGLrjQ (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1csGLrjQ (Marginalman)