I am a long time lurker, and just had an interview with Google where they asked me this question:
Various artists want to perform at the Royal Albert Hall and you are re
It was already mentioned above, but basically keep it simple with a binary tree. You know a binary tree has log N complexity. So you already know what algorithm you need to use. All you have to do is to come up with a tree node structure and use binary tree insertion algorithm to find next available date: A possible one: The tree node has two attributes: d (date of the concert) and d+5 (end date for the blocking period of 5 days). Again to keep it simple, use a timestamp for the two date attributes. Now it is trivial to find next available date by using binary tree inorder insertion algorithm with initial condition of root = null.