Elixir, MapSet
Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n\ndefmodule Solution do\n  @spec circular_game_losers(n :: integer, k :: integer) :
# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\ndefmodule Solution do\n  @spec circular_game_losers(n :: integer, k :: integer) :: [integer]\n  def circular_game_losers(n, k) do\n    winners = do_game(1, 1, k, n, MapSet.new([1]))\n    for x <- n..1, !MapSet.member?(winners, x), reduce: [] do\n      acc -> [x | acc]\n    end\n  end\n\n  defp do_game(cur_pos, i, k, n, winners) do\n    next_pos = cur_pos + (i * k) |> rem(n) |> then(fn pos -> if pos == 0, do: n, else: pos end)\n    if MapSet.member?(winners, next_pos), do: winners,\n    else: do_game(next_pos, i + 1, k, n, MapSet.put(winners, next_pos))\n  end\nend\n```
['Elixir']