GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesHot Potato Circle

Gamified challenge · Queues

Hot Potato Circle

n players numbered 1 to n sit in a circle in order, and player n passes to player 1. Player 1 starts holding the potato and counts as the 1st holder. The potato is passed round the circle, and the k-th holder is out: they leave the circle, and the next player round picks up the potato and counts as the 1st holder of a fresh count.

This repeats until one player is left. Write lastStanding(n, k) (Python: last_standing(n, k)) that returns that player's number. 1 ≤ n ≤ 100 and k ≥ 1; k may be larger than the circle, in which case the count simply goes round more than once.

With n = 5, k = 2, players go out in the order 2, 4, 1, 5, so the answer is 3.

Sign in to play Hot Potato Circle

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account