Skip to content

bookingaroom

bradendubois edited this page Sep 9, 2021 · 7 revisions

Booking a Room

ID: bookingaroom

Difficulty: 1.8

CPU Time: 1 second

Memory: 1024 MB

Solution

Take in the n booked rooms, and find some way to mark their occupancy, and after this, one can simply iterate from 1 to r and check if this room is booked; if not, output it and exit early. If all the rooms have been checked and are taken, output "too late".

Speedup

If n = r, one can simply output "too late" without checking anything.

Clone this wiki locally