Calender 2
Approach 2: Line Sweep Intuition The previous approach works well for the given problem, where we need to avoid triple bookings. However, if the requirements change such as checking for four overlapping bookings, the method becomes less flexible. We'd need to introduce additional lists, for example, to track triple bookings, making the solution harder to maintain and extend. To address this, we can use a more flexible and standard solution: the Line Sweep algorithm. This approach is common for interval-related problems and can easily handle changes, such as checking for four or more overlapping bookings. The Line Sweep algorithm works by marking when bookings start and end. For each booking (start, end) , we mark the start point by increasing its count by 1 (indicating a booking begins), and we mark the end point by decreasing its count by 1 (indicating a booking ends). These marks are stored in a map, which keeps track of the number of bookings starting or endi...