2682. Find the Losers of the Circular Game
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```javascript []
/**
 * @param {number} n
 * @param {number} k
 * @return {number[]}
 */
var circularGameLosers = function(n, k) {
    let visited = new Array(n).fill(false); // To keep track of friends who received the ball
    let current = 0; // Start at the 1st friend, which is index 0 in 0-based indexing
    let turn = 1; // First turn is passing k steps
    
    // Loop until the ball is passed to the same friend again
    while (!visited[current]) {
        visited[current] = true;
        current = (current + turn * k) % n; // Move k steps (scaled by the turn number) in a circular fashion
        turn++;
    }
    
    // Collect all friends who never received the ball
    let losers = [];
    for (let i = 0; i < n; i++) {
        if (!visited[i]) {
            losers.push(i + 1); // Add 1 because the friends are numbered starting from 1
        }
    }
    
    return losers;
};

```
['JavaScript']