精華區beta Marginalman 關於我們 聯絡資訊
1894. Find the Student that Will Replace the Chalk ## 思路 模擬 每一輪會消耗 sum(chalk) 的粉筆 先取mod 再看最後一輪 ## Code ```python class Solution: def chalkReplacer(self, chalk: List[int], k: int) -> int: n = len(chalk) k = k % sum(chalk) for i in range(n): k -= chalk[i] if k < 0: return i return 0 ``` -- http://i.imgur.com/OLvBn3b.jpg -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 185.213.82.95 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1725250616.A.392.html