class Solution:
def LastRemaining_Solution(self, n, m):
# write code here
if not m or not n:
return -1
res = range(n)
i = 0
while len(res)>1:
i = (m+i-1)%len(res)
res.pop(i)
return res[0]
圆圈最后剩下数
最新推荐文章于 2024-02-25 15:58:40 发布