#toyprogrammingchallenge
Here's a freebie!
This problem was asked by Snapchat.
Given an array of time intervals (start, end) for classroom lectures (possibly overlapping), find the minimum number of rooms required.
For example, given [(30, 75), (0, 50), (60, 150)], you should return 2.
@Absinthe i am nor programmer, nor engineer, nor mathematician but in the array you put for the example i see two lectures that do not overlap, so, they can be celebrated in the same classroom and the (30, 75) one overlaps the others, so it can not be in the same classroom. But i do not know how to generalize this or how to code this problem solver...
@Absinthe yes it is clear. If i understood well, always the number of classrooms we need is, the number of overlaps plus one. First we have to find how many overlaps occurs and then add 1. If no overlaps it is like this 0 + 1 and if there are overlaps, call it n. Then the total of classrooms needed are n + 1.
For me the hard part of this problem is to find out how many overlaps occurs using a no drawing method 🤨
Thank you!
@mikelga I was thinking about this earlier.
So you take your first lecture, and assign it to a room
Then you rake your next one, and if it is an overlap you put it in a new room, otherwise put it in the same room.
Then take the next one, if it only overlaps one of the ones in the first room, then whichever one was earlier goes in the room and the one that gets displaced then goes it gets tested against the next room. and so on down the line. When you are out of lectures, count up the rooms.