#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param n int整型
# @param m int整型
# @return int整型
#
class Solution:
def LastRemaining_Solution(self , n: int, m: int) -> int:
# write code here
l=list(range(n))
def inner(ls,m):
if len(ls)==1:
return ls[0]
a=(m-1)%len(ls) if m>len(ls) else m-1
return inner(ls[a+1:]+ls[:a],m)
return inner(l,m)

京公网安备 11010502036488号