Company : MoEngage
Position : SDE 2 - Data Engineer
Round 1:
You are setting up an application to function as your calendar. If adding the event won't result in a double booking, we can add it.
When there is a non-empty intersection between two events—that is, when there is a moment that is shared by both events—double booking occurs.
An integer pair, {start} and {end}, representing a booking on the half-open interval [start, end], can be used to indicate the event.
Implement the MyCalendar class:
MyCalendar() Initializes the calendar object.
boolean book(int start, int end) Returns true if the event can be added to the calendar successfully without causing a double booking. Otherwise, return false and do not add the event to the calendar.
You may make use of the template given below
class MyCalendar {
public:
MyCalendar() {
}
bool book(int start, int end) {
}};
Example
Input1
[[1,6][10, 20], [15, 25], [20, 30], [21, 27], [1, 5]]
i
Output1
[true, true,false,true,false,false]
Input2
[[47,50],[33,41],[39,45],[33, 42],[25,32],[26,35],[19,25],[3,8],[8,13],[18,27]]
Output2
[true, true, false, false, true, false, true, true, true, false]
Round 2:
Round 3:
- Generic Behavioural questions & In-depth project discussions.
Verdict: Offer


