Skip to content

Practice Find the Winner of the Circular Game

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1823
LeetCode Problem

Find the Winner of the Circular Game

Problem Statement

Friends numbered 1 through n sit in clockwise order. Start counting at friend 1, including the starting friend in the count. Count k friends clockwise, wrapping around as needed, and remove the kth friend. Resume counting from the next remaining friend clockwise. Repeat until one remains and return that friend’s number. Follow up: Can you solve this in linear time and constant space?

Source: Find the Winner of the Circular Game on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 5, k = 2
Output
3

# Example 2

Input
n = 6, k = 5
Output
1

Constraints

1 <= k <= n <= 500

Related LeetCode Problems

Practice more problems similar to Find the Winner of the Circular Game.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.