FunctionRacerProblemsRace

Clinic Waiting Room

EasyClassesPython, JavaScript, TypeScript, Java, C++

Implement a class WaitingRoom for a clinic that sees urgent patients first. Write these methods:

A patient never arrives while already waiting, but may come back after being called or leaving. The tests call the methods in sequence and compare every return value. The expected list holds null for the constructor.

Example 1

WaitingRoom()
arrive("Ann", false) returns 1
arrive("Bo", true) returns 2
arrive("Cal", false) returns 3
position_of("Ann") returns 2
call_next() returns "Bo"
call_next() returns "Ann"
leave("Cal") returns true
call_next() returns ""

Bo is urgent, so he is called before Ann even though he arrived later, and Ann stands second while he waits. Cal leaves, so the last call finds nobody.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Classes problems