✅[Python] Simple and Clean, beats 93.99%✅
Intuition\nThe problem asks us to find the losers of a circular game played by n friends sitting in a circle. The game involves passing a ball between friends a
# Intuition\nThe problem asks us to find the losers of a circular game played by n friends sitting in a circle. The game involves passing a ball between friends according to certain rules. The losers of the game are friends who did not receive the ball in the entire game. Our first thought might be to simulate the game and keep track of the friends who have not received the ball yet.\n\n# Approach\n1. We can use a list `res` to keep track of the friends who have not received the ball yet. We initialize `res` with all the friends from 1 to n and remove the first friend since they receive the ball first.\n2. We then use a while loop to simulate the game. In each iteration of the loop, we calculate the next friend to receive the ball using the formula `curr = (curr+(count*k))%n` where `curr` is the current friend holding the ball, `count` is the turn number, and `k` is the number of steps to move in the clockwise direction.\n3. If `curr` is not in `res`, it means that this friend has already received the ball and the game is finished. In this case, we return `res` which contains the losers of the game. Otherwise, we remove `curr` from `res` and increment `count`.\n\n# Complexity\n- Time complexity: $$O(n^2)$$ where n is the number of friends. This is because in the worst case, we need to remove n-1 elements from `res`, and removing an element from a list takes $$O(n)$$ time.\n- Space complexity: $$O(n)$$ since we use a list of size n to keep track of the friends who have not received the ball yet.\n\n# Code\n```\nclass Solution:\n    def circularGameLosers(self, n: int, k: int) -> List[int]:\n        res = [i for i in range(1,n+1)]\n        res.remove(1)\n        curr = 1\n        count = 1\n        while True:\n            curr = (curr+(count*k))%n\n            if curr == 0:\n                curr = n\n            if curr not in res:\n                return res\n            else:\n                res.remove(curr)\n            count+=1                \n```
['Math', 'Simulation', 'Python3']