LeetCode solutions

2791. Find the Losers of the Circular Game

My accepted Python solution to LeetCode problem 2791, Find the Losers of the Circular Game, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.4MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.4MB, accepted 2025-12-31.

python
class Solution:
    def circularGameLosers(self, n: int, k: int) -> List[int]:
        received = [False] * n
        current = 0  # 0-indexed, friend 1 starts
        turn = 1
        
        while not received[current]:
            received[current] = True
            current = (current + turn * k) % n
            turn += 1
        
        losers = []
        for i in range(n):
            if not received[i]:
                losers.append(i + 1)  # Convert to 1-indexed
        
        return losers

Source