My Calendar I | Detailed Approach | Leetcode 729 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029...
This is the 110th Video of our Playlist "Array 1D/2D : Popular Interview Problems" by codestorywithMIK
Interval Based Qns - https://github.com/MAZHARMIK/Intervie...
In this video we will try to solve a good Array Interval Problem : My Calendar I | Detailed Approach | Leetcode 729 | codestorywithMIK
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.
Problem Name : My Calendar I | Detailed Approach | Leetcode 729 | codestorywithMIK
Company Tags : GOOGLE
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Intervie...
Leetcode Link : https://leetcode.com/problems/my-cale...
My DP Concepts Playlist : • Roadmap for DP | How to Start DP ? | ...
My Graph Concepts Playlist : • Graph Concepts & Qns - 1 : Graph will...
My Recursion Concepts Playlist : • Introduction | Recursion Concepts And...
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Intervie...
Instagram : / codestorywithmik
Facebook : / 100090524295846
Twitter : / cswithmik
Subscribe to my channel : / @codestorywithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Summary :
Here’s a short summary of the C++ approaches for the MyCalendar problem:
Approach 1: Brute Force (O(n²) Time, O(n) Space)
This approach uses a vector to store each booked interval and checks every new booking for overlap with all existing intervals. If no overlap is found, the new booking is added.
Since each new booking is compared with all previous ones, the time complexity is O(n²), which is inefficient for large inputs.
Approach 2: Using set with lower_bound (O(n log n) Time, O(n) Space)
This approach uses a set of pair to store intervals, automatically sorted by start time. The lower_bound function is used to find the first interval starting after the new booking and checks for overlap with both the previous and next intervals.
This method is more efficient, with O(n log n) time complexity due to the logarithmic insertion and search in the set.
✨ Timelines✨
00:00 - Introduction
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #newyear2024