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 challengesHospital Triage

Gamified challenge · Priority queues

Hospital Triage

patients[i] = [arrival, severity, duration]: patient i walks in at minute arrival, with severity 1 (critical) up to 5 (minor), and needs duration minutes with the doctor. There is one doctor, who treats one patient at a time and never stops a treatment halfway.

Whenever the doctor is free, they call the most urgent patient who has already arrived: lowest severity first, then earliest arrival, then lowest index. If nobody is waiting, they wait for the next arrival. Write triage(patients) that returns the patients' indices in the order they are treated.

For [[0, 3, 4], [1, 1, 2], [2, 2, 3], [3, 1, 1]] the answer is [0, 1, 3, 2]: patient 0 is alone at minute 0, and when the doctor is free at minute 4 the critical patients 1 and 3 go before patient 2.

Sign in to play Hospital Triage

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