731. My Calendar II | intervals | Line Sweep algo | Leetcode Daily Challenge | DSA | Java

preview_player
Показать описание
Problem Name:
731. My Calendar II

Problem Statement:
You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a triple booking.

A triple booking happens when three events have some non-empty intersection (i.e., some moment is common to all the three events.).

The event can be represented as a pair of integers start and end that represents a booking on the half-open interval [start, end), the range of real numbers x such that start = x end.

Implement the MyCalendarTwo class:

MyCalendarTwo() 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 triple booking. Otherwise, return false and do not add the event to the calendar.

Problem Link:

Solution Link:

Graph Playlist:

Java Plus DSA Placement Course Playlist:

Java Plus DSA Sheet:

Notes:

Telegram Link:

Ultimate Recursion Series Playlist:

Samsung Interview Experience:

Company Tags:
Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung

Timestamp:
0:00 - Introduction

#ShashwatTiwari #coding​​ #problemsolving​
Рекомендации по теме
Комментарии
Автор

Two corrections
1) 7:21 start>=end means interval does not exist, I missed explaining start == end case because end is exclusive range example [20, 20] is invalid because range is actually 20 to 19 which is invalid. where as [16, 20] is valid as the range is 16 to 19
2) 12:12 name of the algorithm is Line Sweep.

Like target is 130, Please do like if you were able to understand the explanation as well as the code.

shashwat_tiwari_st
Автор

What if one interval is ending at 5 where we insert {5, -1}and another interval starting at 5 where we insert {5, +1} .. Will it work for such case.. Like in this case insertion and deletion at same point will make the count as 0.. Will it work for such cases..??

tejas
Автор

Bhai aap boht he tagda pdha rhe ho ! Ye logic building itni strong kaise hogi ?

Real_Gangsta-qh
welcome to shbcf.ru