Hospital OPD Patient Priority Queue
Hospital OPD Patient Priority Queue
MediumArrays100% accepted
A Delhi hospital's OPD system receives patients with urgency levels 1-10. Nurses must reorganize the queue to bring high-urgency patients (level >= 7) to the front immediately while maintaining the relative order of all patients. Return the reordered patient indices.
Approach
Given an array of urgency levels, partition it to place high-urgency patients (>= 7) first while preserving relative order within each group.
Input
n=8
threshold=7
arr=[5,8,3,9,6,7,4,8]
Output
[1,3,5,7,0,2,4,6]
More Arrays problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards