Booking a Room

Question

Solution

Idea

Time Complexity: O(n)O(n)

My idea is to use frequency table, which is part of counting sort. The first O(n)O(n) is used to get the input and it cannot be optimized further I think. The second O(n)O(n) is to use linear search to find the available room, which I think cannot be modified either because there is no pattern, so binary search doesn't work.

Code

https://github.com/mendax1234/Coding-Problems/blob/main/kattis/bookingaroom/bookingaroom.c

Last updated