gdgpce/DSA-Challenges-2024

Circular Queue Game

Open

#17 opened on Oct 7, 2024

 (8 comments) (0 reactions) (1 assignee)C++ (12 forks)auto 404
good first issuehacktoberfest

Repository metrics

Stars
 (2 stars)
PR merge metrics
 (PR metrics pending)

Description

Problem: A group of n friends are playing a circular game where they are positioned in a circle and numbered sequentially from 1 to n in a clockwise direction. The game proceeds according to the following rules:

  • Starting at friend 1.
  • Count forward k friends in the clockwise direction, wrapping around the circle if necessary. The count includes the starting friend.
  • The friend at the end of the count exits the game.
  • The game continues, starting from the next friend in the clockwise direction of the friend who was eliminated.
  • Repeat the process until only one friend remains, and that friend is declared the winner.

The input consists of two integers:

  • n: The total number of friends sitting in a circle (1 <= n <= 500).
  • k: The number of friends to count clockwise, including the starting friend (1 <= k <= n).

The output should be the integer representing the friend who wins the game(the last friend remaining in the circle).


  1. Follow and Read the Contributing Guidelines.

  2. Only the assigned person is allowed to raise the PR on this Issue.

  3. To get this issue assigned to you comment on this issue, along with your name, branch, year and college name.

Note: Make sure to put the question under the relevant folder structure, and then make another folder having the question name and inside that folder you can write your solution in any preferred language.

Contributor guide