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 challengesPrinter Priority Line

Gamified challenge · Queues

Printer Priority Line

Print jobs wait in a line. priorities[i] is the priority of job i (bigger is more urgent), and job 0 is at the front. The printer repeats: take the job at the front; if any job still waiting has a higher priority, put the taken job at the back of the line; otherwise print it.

Write printTurn(priorities, mine) (Python: print_turn(priorities, mine)) that returns on which turn job mine is printed: 1 if it is the first page out, 2 if second, and so on. Jobs with equal priority don't block each other.

For [2, 1, 3, 2] with mine = 2: job 0 and job 1 go to the back, then job 2 (priority 3) prints first, so the answer is 1. For [1, 1, 9, 1, 1, 1] with mine = 0, the answer is 5.

Sign in to play Printer Priority Line

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