Find the Winner of the Circular Game
Medium · Queue & Deque · about 15 minutes
Asked at Bloomberg, Meta, Microsoft, Amazon.
n friends sit in a circle numbered 1..n clockwise. Starting from friend 1, count k friends clockwise (including the one you start on); the last friend counted leaves the circle. Counting restarts from the friend just after the one who left. Return the number of the last remaining friend.