My Calendar Problem Statement
Given N
events, each represented with a start
and end
time as intervals, i.e., booking on the half-open interval [start, end). Initially, the calendar is empty. A new event can be added only if it does not cause a triple booking, where a triple booking means any three events have a common overlapping time.
Task:
Process the N
events, and for each, determine if it can be added to the calendar without causing a triple booking. Return 'True' if it can be added successfully, otherwise return 'False'.
Input:
The first line contains an integer ‘T’, the number of test cases. For each test case, the first line contains an integer ‘N’, the number of events. The next ‘N’ lines contain two space-separated integers ‘Start’ and ‘End’ for the event intervals.
Output:
For each test case, print 'N' space-separated 'True' or 'False' for each event indicating whether it can be added without causing a triple booking. Output for each test case should be on a separate line.
Example:
Input:
2
3
10 20
15 25
20 30
2
5 10
15 20
Output:
True False True
True True
Constraints:
1 ≤ T ≤ 10
1 ≤ N ≤ 1000
0 ≤ Start, End ≤ 109
Note:
You are not required to print anything as input/output handling is managed elsewhere. Implement the given functions accordingly.

AnswerBot
4mo
Given N events with start and end times, determine if each event can be added to the calendar without causing a triple booking.
Iterate through each event and check if adding it causes a triple booking...read more
Help your peers!
Add answer anonymously...
Microsoft Corporation SDE-2 interview questions & answers
A SDE-2 was asked Q. How would you design a video feed API?
A SDE-2 was asked Q. Given a column number, return its corresponding Excel column address.
A SDE-2 was asked Q. Given a string and a matrix of characters, determine if the string exists in the...read more
Popular interview questions of SDE-2
A SDE-2 was asked Q1. How would you design a video feed API?
A SDE-2 was asked Q2. Given a column number, return its corresponding Excel column address.
A SDE-2 was asked Q3. Given a string and a matrix of characters, determine if the string exists in the...read more
>
Microsoft Corporation SDE-2 Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

