1 # -*- coding:utf-8 -*- 2 class Solution: 3 def LastRemaining_Solution(self, n, m): 4 if n == 0: 5 return -1 6 if n == 1: 7 return 0 8 dp = [0] * (n+1) 9 dp[0] = -1 10 dp[1] = 0 11 for i in range(2,n+1): 12 dp[i] = (dp[i-1] + m) % i 13 print(dp) 14 return dp[n] 15 # write code here