You are given 'n' appointments. Each appointment contains startime and endtime. You have to retun all conflicting appointments efficiently starttime and endtime can range from a few min to few years. I saw the post: FInd overlapping appointments in O(n) time? which is very similar to this. But a doubt remains.
My question is that if we have a sorted schedule given, say : (6:30-6:35), (6:40-7:10) (7:25-7:40), (7:35-7:50) and so on.
Can we not traverse the schedule list and make sure that the next appointment should begin ONLY after the previous one is over? In that case we're applying a very tight bound on the possible time for scheduling an appointment. In this example, we know that the appointment beginning at 7:35 is before last appointment ends (7:40) so it is a conflict. Do we really need to complicate the solution by creating a tree or hash map as mentioned in the most rated solution in link for similar question?
Please point out cases which can bypass this check and prove this condition invalid.