Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Find the Losers of the Circular Game

XPChallenge Points: 10
levelLevel: Easy

There are n friends sitting in a circle, numbered from 1 to n.
The game works like this:

  • The 1st friend starts with the ball.

  • On the 1st move, the ball is passed k steps clockwise.

  • On the 2nd move, the ball is passed 2 * k steps clockwise.

  • On the 3rd move, it is passed 3 * k steps clockwise, and so on.

The game stops when any friend receives the ball for the second time.

Your task is to return a list of all friends who never received the ball, sorted in increasing order.

Example 1:

Input: n = 6, k = 1

Output: [4,5,6]

Explanation:

Friends 1, 2, and 3 get the ball before 1 gets it again. Others never receive it.

Example 2:

Input: n = 7, k = 3

Output: [2,5,6,7]

Explanation:

Only friends 1, 4, and 3 got the ball before repetition occurred.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result