2682. Find the Losers of the Circular Game | Dart Solution | Time O(n) | Space O(n)
ApproachThe solution simulates the ball-passing game by tracking winners and losers:

Initialize data structures:

losers: List of all players except player 1 (
## Approach

The solution simulates the ball-passing game by tracking winners and losers:

1. Initialize data structures:
   - `losers`: List of all players except player 1 (initially assumed all are losers)
   - `winners`: List starting with player 1
   - `players`: List of all player numbers from 1 to n

2. Game simulation:
   - Track current position and move multiplier
   - Calculate next position using modulo for circular movement
   - If current player is already a winner, end game
   - Otherwise:
     - Add current player to winners
     - Remove current player from losers

3. Position calculation:
   - Use formula: `(position + move * k) % players.length`
   - Increment move counter after each turn

The solution efficiently handles the circular nature of the game while maintaining separate lists for winners and losers.

## Complexity

- Time complexity: $$O(n)$$
  The solution iterates through players until a repeat occurs, which in worst case is O(n). The `contains` and `removeWhere` operations are also O(n), making the overall complexity linear.

- Space complexity: $$O(n)$$
  The solution maintains three lists (`losers`, `winners`, `players`) each potentially containing up to n elements, resulting in linear space complexity.


# Code
```dart []
class Solution {
  List<int> circularGameLosers(int n, int k) {
    List<int> losers = List.generate(n - 1, (int index) => index + 2);
    List<int> winners = [1];
    List<int> players = List.generate(n, (int index) => index + 1);
    int position = 0;
    int move = 1;
    while (true) {
      position = position + move * k >= players.length
          ? (position + move * k) % players.length
          : position + move * k;
      move++;
      if (winners.contains(players[position])) {
        break;
      } else {
        winners.add(players[position]);
        losers.removeWhere((player) => player == players[position]);
      }
    }
    return losers;
  }
}

```
['Dart']