Meeting Rooms III | Detailed Intuition | Brute Force | Optimal | Leetcode 2402

  Рет қаралды 6,369

codestorywithMIK

codestorywithMIK

Күн бұрын

iPad PDF Notes - github.com/MAZHARMIK/Intervie...
Whatsapp Community Link : www.whatsapp.com/channel/0029...
This is the 84th Video of our Playlist "Array 1D-2D : Popular Interview Problems".
We will try to understand the thought process behind solving interview based problems and also see 2 Approaches for this.
Problem Name : Meeting Rooms III | Leetcode 2402
Company Tags : GOOGLE
My solutions on Github : github.com/MAZHARMIK/Intervie...
Leetcode Link : leetcode.com/problems/meeting...
Approach Summary :
Approach-1 (Brute Force - Do as said):
This approach sorts meetings by their starting times and iterates through them.
It maintains vectors to track each room's last available time and the count of times each room is used.
For each meeting, it finds the first available room or the room with the earliest availability if no room is available.
The result is the room with the highest usage count.
Approach-2 (Use priority Queue to find the first available meeting room):
Similar to Approach-1, it sorts meetings by starting times.
It employs two priority queues: usedRooms to store occupied rooms with their earliest empty times and unusedRooms to manage available rooms.
It iterates through meetings, updating room availability using priority queues.
If a room is available, it is marked as used; otherwise, it finds the room with the earliest available time and updates its availability.
The result is the room with the highest usage count.
Both approaches efficiently handle meeting scheduling and room availability to determine the most booked room, with Approach-2 using priority queues for optimization.
My Recursion Concepts Playlist : • Introduction | Recursi...
My DP Concepts Playlist : • Roadmap for DP | How t...
My Graph Concepts Playlist : • Graph Concepts & Qns -...
My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
Subscribe to my channel : / @codestorywithmik
Instagram : / codestorywithmik
Facebook : / 100090524295846
Twitter : / cswithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Timelines : ⏰
00:00 - Problem Explanation using Example
04:50 - Do as asked (Brute Force) + Story
22:33 - Code Brute Force
34:15 - Optimal Approach Intuition
38:59 - Build story for Optimal
52:45 - Time and Space Complexity
54:00 - Coding it up
#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 #2024 #newyear

Пікірлер: 101
@pratiksahu1539
@pratiksahu1539 21 күн бұрын
Thank you so much sir!
@codestorywithMIK
@codestorywithMIK 21 күн бұрын
This means a lot. Thank you Pratik for this kind gesture ❤️
@saanchit1
@saanchit1 5 ай бұрын
Again, mark my words, this channel will surpass Neetcode/striver's subscribers someday, pin this !
@wearevacationuncoverers
@wearevacationuncoverers 5 ай бұрын
true 🔥
@riyanshbiswas
@riyanshbiswas 5 ай бұрын
I never understood a single word striver spoke, i have no idea how people understand his videos.
@akbar55555shaikh
@akbar55555shaikh 4 ай бұрын
Don't compare, their content is nothing (never liked) This is an awesome channel.
@aakritidubey5920
@aakritidubey5920 5 ай бұрын
Sir please never ever stop making these videos , Its because of you that I am confident enough to approach the problems on my own,specially dp ones.Thanks again sir.
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Means a lot 🙏❤️ Apologies for the delay. Actually i have been occupied this weekend due to some prescheduled plans. Thank you for understanding ❤️🙏
@simplify5251
@simplify5251 5 ай бұрын
your explanation is even better than striver. Hats Off man. Keep teaching
@swarnavachakrabarti8970
@swarnavachakrabarti8970 5 ай бұрын
Your videos are the definition of phenomenal teaching. Every step of explanation is awesome
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
It means a lot Apologies for the delay. Actually i have been occupied this weekend due to some prescheduled plans. Thank you for understanding ❤️🙏
@wearevacationuncoverers
@wearevacationuncoverers 5 ай бұрын
indeed
@MD_SAMEER___
@MD_SAMEER___ 5 ай бұрын
Just love the way you teach ❤ You are the most underrated teacher May Allah help you in your journey
@himanshu_27tt
@himanshu_27tt 5 ай бұрын
by far the best explanation i have seen on youtube
@vinayaksinghal
@vinayaksinghal 5 ай бұрын
You give the best of explanations.
@gui-codes
@gui-codes 2 ай бұрын
🔥 cant' express in words. i think you are clearly the best dsa content creator till now. If you had come years ago, then you would have much more subscribers than any dsa youtuber out there. I suggest everyone about your channel
@aws_handles
@aws_handles 5 ай бұрын
I can bet, your explanations are better than any paid platform out there, or any famous youtuber out there. Hats off
@vivekgupta_3085
@vivekgupta_3085 5 ай бұрын
Underrated Channel !! You make us fall in love with recursion , dp or any problem . Paid Courses se bhi better ho
@hengulrajsaikia9227
@hengulrajsaikia9227 5 ай бұрын
Dude, I almost though of the optimised solution except for the second priority queue containing the available rooms. You explained it so well.
@abhishekkarn8918
@abhishekkarn8918 Ай бұрын
Next level explanation. Well done man. Absolutely amazing explanation. Don't stop giving tutorials like these. You are truly a gem.
@abcd76820
@abcd76820 5 ай бұрын
thanks mik , i avoid watching other tutorial from morning coz i knw when ur vdeo arrive it explains everthing in detail and i am able to code after listening ur logic. thanks a lot buddy !!!!
@ArjunSingh-pm2vt
@ArjunSingh-pm2vt 5 ай бұрын
Bro explained entire business model of OYO
@factholicdunyia2049
@factholicdunyia2049 5 ай бұрын
I'm excited to see the video. I've been checking your channel all morning. Can't wait! 😄
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Thank you Apologies for the delay. Actually i have been occupied this weekend due to some prescheduled plans. Thank you for understanding ❤️🙏
@amitshukla2268
@amitshukla2268 5 ай бұрын
Thanks a lot bhaiya, subh aapki vid search kia tha iss question ke lie lekin nahi mili, dusro ka dekha toh kuch smz ni aaya ki kyu 2 min heap use kia hai , abb jakr sab kuch clear ho gya, You are a gem bhaiya ❤❤
@EB-ot8uu
@EB-ot8uu 5 ай бұрын
Bawal explanation and bawal channel. Extremely underrated. This guys is a hidden legend
@acceleratorlevel645
@acceleratorlevel645 5 ай бұрын
the fact that the code i came up on my own was so similar to yours is a sign that i have learnt so much from you ! thank you so much for your daily lessons !
@shivam875S
@shivam875S 5 ай бұрын
khatarnak explaination sir keep making story to code video i love the way you approach a problem ✌✌❤❤
@rounaq_khandelwal
@rounaq_khandelwal 5 ай бұрын
Though I spent 2 hours on this question, but I am really happy to have a strong hold over the concepts and illustrations taught in the lecture! Thanks MIK
@user-ub2is4rs4x
@user-ub2is4rs4x 5 ай бұрын
Are guruji. Ek hi dil hai, kitni baat jeetoge. Gajab parhate ho aap 🔥🔥
@viditvaish7317
@viditvaish7317 5 ай бұрын
tanq very much sir .Aap jo har ek minute cheej kaise hui aur kyu huyi uska intution dete hain vo bahut amazing hai aisa koi bhi nahi karta cheeze ekdum crystal clear ho jati hain .Thanq very very much sir
@wearevacationuncoverers
@wearevacationuncoverers 5 ай бұрын
You are just an awesome tutor. No words to express this level of teaching. Man I am just speechless.
@harchitgulati3065
@harchitgulati3065 5 ай бұрын
nice explanation sir ! I went to every channel to understand the concept but this was the best ..I easily understood
@ugcwithaddi
@ugcwithaddi 5 ай бұрын
After watching many other videos since morning, this is where I get completely satisfied understanding. Thank you so much. Was waiting for your video since morning
@Thriftinghai
@Thriftinghai 5 ай бұрын
I only wait for your videos. As usual, fantastic explanation. Thank you so much
@souravjoshi2293
@souravjoshi2293 5 ай бұрын
Goodness. Hats off to this detailed explanation. And thanks a lot for video tags as well.
@kshitijgarg2609
@kshitijgarg2609 5 ай бұрын
Best explanatory video which is fruitful
@kshitijgarg2609
@kshitijgarg2609 5 ай бұрын
The java solution approach 2 is stuck at one test case, the rooms are 100 and test case is quite big, so please do check that code again. Thank you so much for your consideration.
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Updated and corrected. Kindly check now. Thank you ❤️🙏
@23cash86
@23cash86 5 ай бұрын
Best explanation , after watching brute force I figured out the optimal on my own 👌
@varunvarun5723
@varunvarun5723 5 ай бұрын
Thanks for your amazing support
@thor1626
@thor1626 5 ай бұрын
I was using a Hashmap and a pq, but could not figure out what to do when multiple rooms get free, how to select the smallest room out of them, Watched your video and the intuition hit me faster than a bullet train. Also the brute force method is great too. Thanks for these videos, also please continue the recursion series, it's too good.
@umeshbisht1054
@umeshbisht1054 5 ай бұрын
Thanku bhaiya ❤❤
@pradeepranjan8226
@pradeepranjan8226 5 ай бұрын
loved it
@sauravjos
@sauravjos 5 ай бұрын
Could you also start making videos for important questions 3, 4 from Weekly contests? That would be of great help.
@ankurtiwari9621
@ankurtiwari9621 5 ай бұрын
Great Explanation .. Please help in providing solutions of Medium / Hard of weekly & biweekly contest..
@mr_stranger3867
@mr_stranger3867 5 ай бұрын
Nice video bhaiya😁😁 Btw aap konsa pentab use krte ho sikhane ke liye ?
@Ashu-Tosh650
@Ashu-Tosh650 5 ай бұрын
Sir you are amazing
@nishantdehariya5769
@nishantdehariya5769 4 ай бұрын
nice
@bhuppidhamii
@bhuppidhamii 5 ай бұрын
please, also make a video on Meeting Rooms 1&2
@ShivamTiwari-yl7xv
@ShivamTiwari-yl7xv 5 ай бұрын
Nice solution :)
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Thank you 🙏 Apologies for the delay in upload today . Actually i have been occupied this weekend due to some prescheduled plans. Thank you for understanding ❤️🙏
@tutuimam3381
@tutuimam3381 5 ай бұрын
❤❤❤❤
@user-ix8ce9cq3e
@user-ix8ce9cq3e 5 ай бұрын
Bhaiya Need Advice 🙏 Mai leetcode question ke approach ko thoda bahut sahi direction pe soch leta hoon but ultimately solve nhi hota aur contest mai to 2 questions tak hi hote hai 5 - 6 months se consistent bhi coding kar raha hoon abhi jaake sirf Graph pending reh raha hai bakki Leetcode POTD pichle 20 din se kar raha hoon .
@Sahilsharma-sk5vr
@Sahilsharma-sk5vr 5 ай бұрын
wow. wow
@tharunkumar8133
@tharunkumar8133 5 ай бұрын
Hi. There is a small bug in Java code which you uploaded to github. While writing the lambda for usedRooms we need to consider a case where starting times are equal. In this case we need to again sort the array based on ending times. Without this 81/82 cases are passing. existing lambda: (a, b) -> Long.compare(a[0], b[0]) fix for it: (a,b)->Long.compare(a[0],b[0])==0 ? Long.compare(a[1],b[1]) : Long.compare(a[0],b[0])
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Corrected and updated. Thanks a lot 🙏
@shakti5521
@shakti5521 5 ай бұрын
Very nice explanation video, please share your Dsa sheet.
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Thank you 🙏 docs.google.com/spreadsheets/d/1LO1BLTebhrcRfEpPjIOutKvOFSFaFM3Ph1EjA12x_zE/edit?pli=1#gid=740761817
@aksharbrahm4618
@aksharbrahm4618 5 ай бұрын
Nice Explanation. I really appreciate.. But wanted to ask that why dont you write code in java ?
@23cash86
@23cash86 5 ай бұрын
✌️👍👍
@ankitsahu2305
@ankitsahu2305 5 ай бұрын
class Solution { public: struct myCmp { bool operator()(pair &a, pair &b) { if(a.first>b.first) return true; else if(a.first==b.first) return a.second>b.second; else return false; } }; static bool comparator(vector &a, vector &b) { return a[0]
@adityabalachandran8675
@adityabalachandran8675 5 ай бұрын
Hello MIK in bruteforce approach shouldnt we also need to add a break statement after we found a room as such otherwise it will also will replace other room times accidentally ? 30:33
@sudhadevi6692
@sudhadevi6692 5 ай бұрын
Did u get the ans?
@adityabalachandran8675
@adityabalachandran8675 5 ай бұрын
@@sudhadevi6692 yeah it was solved later in the video itself
@sudhadevi6692
@sudhadevi6692 5 ай бұрын
@@adityabalachandran8675 ya seen
@gauravbanerjee2898
@gauravbanerjee2898 5 ай бұрын
Was wating for your video since morning , thank you so much bhaiya ❤❤
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Apologies for the delay. Actually i have been occupied this weekend due to some prescheduled plans. Thank you for understanding ❤️🙏
@gauravbanerjee2898
@gauravbanerjee2898 5 ай бұрын
@@codestorywithMIK No issues bhaiya, hats off to your consistency, making videos regularly with this much detailed explanation is not an easy job. You must be a pro at time management, so many things to learn from you 😇. Thanks a lot for everything. ❤❤
@bhuppidhamii
@bhuppidhamii 5 ай бұрын
hello bhaiya, Meeting Rooms 1 & 2 are locked in LeetCode, can you tell us where to practice those alternatively (please share links if possible)
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Find them in Lintcode
@bhuppidhamii
@bhuppidhamii 5 ай бұрын
ok sir@@codestorywithMIK
@ranvijaysharma6697
@ranvijaysharma6697 2 ай бұрын
Agar same hi priority queue me 0 se initialize krke rooms push kr de to kaam ni chalega?
@ranvijaysharma6697
@ranvijaysharma6697 2 ай бұрын
kyuki wo to hmesaa top pr mil jayenge aur hme hmesaa min hi chahiye. index second element hai pair ka to wo index wise bhi sorted hoga room pq me. {0,0}, {0,1},{0,2}.. aise
@ranvijaysharma6697
@ranvijaysharma6697 2 ай бұрын
kr ke dekha ni hua.. kyuki ek heap ke case me ye pehle saare empty fill krta hai.. jbki aisa ni krna hai.. used room agr available hai to wo pehle assign krna hai.
@dayashankarlakhotia4943
@dayashankarlakhotia4943 5 ай бұрын
your java solution for apporach 2nd is not working in solution you room conver in int then insert pq.but your pq.long?
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Corrected and updated. Thanks a lot 🙏
@Abhay14
@Abhay14 5 ай бұрын
bhaiya jo tummhari DSA sheet h usse drive pr upload krdo with your yt sol link
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Sure thing. Let me do it today after office Thanks for your precious suggestion ❤️🙏
@Abhay14
@Abhay14 5 ай бұрын
and bhaiya try krna Topic wise question dalne ka like array,string, rec, dp, backtracking, linked list etc and easy medium hard bhi i know ye kafi time consuming h but it will help us a lot if you want reference pls use my sheet i make this sheet for revision purpose docs.google.com/spreadsheets/d/105oeZV6LOddHNGeBx2CEWIhFQnI62HfLODCGlRwBG90/edit#gid=0 @@codestorywithMIK
@JagannathDebGunin
@JagannathDebGunin 5 ай бұрын
Dada can you please do permutation ii of Leetcode? ...
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Sure. I will try to bring that in my Recursion playlist asap
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Also, Apologies for the delay in upload today. Actually i have been occupied this weekend due to some prescheduled plans. Thank you for understanding ❤️🙏
@dhairyachauhan6622
@dhairyachauhan6622 5 ай бұрын
Bhaiya aaj ka contest bhaut bhura hua.... ab toh self doubt ho rha hai :( dpp toh ho jate hai fir contest kyu nhi ho paa rha 😔😔
@anshumaan1024
@anshumaan1024 5 ай бұрын
kyo kitne hue ?
@dhairyachauhan6622
@dhairyachauhan6622 5 ай бұрын
@@anshumaan1024 2 (1 and 3)
@dhairyachauhan6622
@dhairyachauhan6622 5 ай бұрын
@@anshumaan1024 1st and 3rd
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Let me check the qns and try to upload this week. Don’t worry it happens a lot of times. Happened to me a many more time before. Also, Apologies for the delay in uoload today. Actually i have been occupied this weekend due to some prescheduled plans. Thank you for understanding ❤️🙏
@dhairyachauhan6622
@dhairyachauhan6622 5 ай бұрын
@@codestorywithMIK bhaiya no worries for the delay thanks for keeping my sprit up :)
@ninadbhase7071
@ninadbhase7071 5 ай бұрын
kindly share your SDE sheet
@codestorywithMIK
@codestorywithMIK 5 ай бұрын
Thank you 🙏 docs.google.com/spreadsheets/d/1LO1BLTebhrcRfEpPjIOutKvOFSFaFM3Ph1EjA12x_zE/edit?pli=1#gid=740761817
@Abhay14
@Abhay14 5 ай бұрын
bhaiya i did the Min refueling stops problem class Solution { public: int minRefuelStops(int target, int startFuel, vector& stations) { int ans = 0; // total no of station where my car stop int count = 0; //this calculate the distance where my car can reach priority_queuepq; int i = 0; while(count < target){ count += startFuel; //itna travel kr paeggi meri car startFuel = 0; //fuel khtm if(count >= target) return ans; //storing all stations fuel in pq while(i < stations.size() && count >= stations[i][0]){ //yha hgegga pq.push(stations[i][1]); i++; } if(pq.empty()) return -1; startFuel += pq.top(); pq.pop(); ans++; } return ans; } };
@rajrajesh1669
@rajrajesh1669 5 ай бұрын
Sir please teach in English...
아이스크림으로 체감되는 요즘 물가
00:16
진영민yeongmin
Рет қаралды 60 МЛН
- А что в креме? - Это кАкАооо! #КондитерДети
00:24
Телеканал ПЯТНИЦА
Рет қаралды 7 МЛН
DEFINITELY NOT HAPPENING ON MY WATCH! 😒
00:12
Laro Benz
Рет қаралды 58 МЛН
100❤️
00:19
MY💝No War🤝
Рет қаралды 23 МЛН
Meeting Rooms III - Leetcode 2402 - Python
16:16
NeetCodeIO
Рет қаралды 19 М.
My 2 Year Journey of Learning C, in 9 minutes
8:42
VoxelRifts
Рет қаралды 574 М.
Live Coding a Gambling Strategy on Stake.com
32:41
Harkirat Singh
Рет қаралды 78 М.
MEETING ROOMS III | LEETCODE # 2402 | PYTHON HEAP SOLUTION
18:40
Cracking FAANG
Рет қаралды 6 М.
Ep : 5 I Jain Philosophy: An Introduction I Dr Vikas Divyakirti
3:29:27
Vikas Divyakirti
Рет қаралды 3,9 МЛН
Group Anagrams | without sorting | Google | Leetcode 49
14:24
codestorywithMIK
Рет қаралды 5 М.
Single-Threaded CPU | Detailed Explanation | Google | Live Coding
39:01
codestorywithMIK
Рет қаралды 3,7 М.
아이스크림으로 체감되는 요즘 물가
00:16
진영민yeongmin
Рет қаралды 60 МЛН