Meeting Rooms III - Leetcode 2402 - Python

  Рет қаралды 18,910

NeetCodeIO

NeetCodeIO

Күн бұрын

🚀 neetcode.io/ - A better way to prepare for Coding Interviews
🧑‍💼 LinkedIn: / navdeep-singh-3aaa14161
🐦 Twitter: / neetcode1
⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
Problem Link: leetcode.com/problems/meeting...
0:00 - Read the problem
0:30 - Drawing Explanation
8:48 - Coding Explanation
leetcode 2402
#neetcode #leetcode #python

Пікірлер: 42
@NeetCodeIO
@NeetCodeIO 4 ай бұрын
Sorry I'm a little late today, but better late than never! 🚀🚀
@satyamjha68
@satyamjha68 4 ай бұрын
No problem! Love your leetcode content as always!
@AmrElmohtaseb
@AmrElmohtaseb 4 ай бұрын
Thank you!! This is the video I wait for every day.
@aseshshrestha8012
@aseshshrestha8012 4 ай бұрын
Why did you stop posting in your another channel? Why another channel?
@SanketBhat7
@SanketBhat7 4 ай бұрын
I solved it without help!!! But at what cost😅? I took 3 hours, used a "TreeMap"🙃🙃 and my solution beats only 5% of others. But I am still happy that I am able to solve, something is better than nothing. Came here to learn how to do it the right way.
@yang5843
@yang5843 4 ай бұрын
fwiw my java solution beats 23%, I posted the code as a comment to this video
@SairamDasari2000
@SairamDasari2000 4 ай бұрын
I thought my streak is going to end , thanks mate ❤❤
@user-jf7xb1lb2z
@user-jf7xb1lb2z 4 ай бұрын
Bro you are a lifesaver, there was absolutely no way I could have solved this on my own.
@NH-hq7ly
@NH-hq7ly 4 ай бұрын
Thanks for the video. My level is too low to solve this hard question. I'm just here to learn
@aniketpatel8655
@aniketpatel8655 4 ай бұрын
You explained things so easily! Thank you, dude.
@hoyinli7462
@hoyinli7462 4 ай бұрын
I love your lc video. I can see you've uploaded a solution, which means I can learn from you when I can't solve it. At the same time I don't see any spoiler, so I can try first. Great video as always!
@razataggarwal7365
@razataggarwal7365 4 ай бұрын
Same thought process ! 👌
@nicolasguillenc
@nicolasguillenc 4 ай бұрын
This one was rough, thanks man!
@sherloccode6272
@sherloccode6272 4 ай бұрын
Love this explanation
@shashwatkumar3079
@shashwatkumar3079 4 ай бұрын
I figured out what I needed to do but cant't figure out the approach of using two heaps. Good question.
@trueArcticFox
@trueArcticFox 4 ай бұрын
Thanks!
@chaitanyasharma6270
@chaitanyasharma6270 4 ай бұрын
explain meeting rooms 2 with priority queue as well
@hangchen
@hangchen 4 ай бұрын
7 days ago, just about time for me!
@iamabominable7462
@iamabominable7462 4 ай бұрын
Never been here this early lol Love your content 😄
@NeetCodeIO
@NeetCodeIO 4 ай бұрын
ty :)
@tarunmali6228
@tarunmali6228 2 ай бұрын
Hi, when this problem will be added to the neecode website list?
@suvajitchakrabarty
@suvajitchakrabarty 4 ай бұрын
When rooms are not available, and we look at the used heap, why do we only pop the first value from used. What if there were other values with the same end time, would we not want to pop all the nodes with the same end time, and use the one with the minimum room number?
@suvajitchakrabarty
@suvajitchakrabarty 4 ай бұрын
Ah okay never mind, I guess I realized later that the min heap comparator function will take care of that automatically. Sorry, was using Javascript, and was using a class for the min heap that I wrote myself.
@sophiophile
@sophiophile 4 ай бұрын
Can you use heapq methods like heappop on a list that you never heapified like that? 3:16 If so that's awesome. Does that mean if your list is already a (eg min) heap, those operations just work?
@NeetCodeIO
@NeetCodeIO 4 ай бұрын
Yeah exactly, heaps are stored as lists in python. Even in languages like Java they are implemented with arrays / ArrayList under the hood
@sophiophile
@sophiophile 4 ай бұрын
@@NeetCodeIO That's awesome. That's the thing I love about Python. You always discover new ways that something can be done a little lazier, haha. I always assumed that while they could be accessed like lists, it was either: * some magic under the hood so you could use the same methods as on a normal list object * a list with the same data was generated when you needed to interact with that object type, while there is some tree that is the actual heap somewhere else in memory
@WatchTower71
@WatchTower71 4 ай бұрын
How long did it take for you to come up with a solution for this? I came up with a solution but because of the constraints it failed 10 TCs.
@synthesiakin2543
@synthesiakin2543 4 ай бұрын
What do you use to draw on the screen?
@NeetCodeIO
@NeetCodeIO 4 ай бұрын
paint 3d and a mouse
@yaswanthkosuru
@yaswanthkosuru 4 ай бұрын
​@@NeetCodeIOare u joking 😅
@navaneethku
@navaneethku 4 ай бұрын
I don't think he is joking@@yaswanthkosuru
@vivekragireddy6941
@vivekragireddy6941 4 ай бұрын
can anyone post the c++ version of code for this?
@Moch117
@Moch117 4 ай бұрын
You solved without hints ?
@JourdanOoi-wp2lh
@JourdanOoi-wp2lh Ай бұрын
this solution no longer working for anyone else?
@electricindro2236
@electricindro2236 4 ай бұрын
Brilliant!
@alieeldeenahmed2278
@alieeldeenahmed2278 4 ай бұрын
I reach test cases 69/82 I give up 😅😅
@bouzie8000
@bouzie8000 4 ай бұрын
I actually don't think this is a leetcode hard, more like a medium. I think there are enough cues in the question that let you know exactly what data structure to use to solve this. It also helps if you've solved meeting rooms II before. But I see a lot of comments saying this is difficult. I love how we all assimilate problems differently and what is hard to some is straightforward to others and vice versa - because best believe there are some problems I could never solve in a 45 minute interview that are so called medium or even easy 😂. Which is why as much as we all grind leetcode we can't afford to ignore the amount of good fortune that needs to be present for us to land jobs at top firms
@zweitekonto9654
@zweitekonto9654 4 ай бұрын
The logic building is medium. But implementation is definitely hard. Too many moving parts and variables to keep track of to come up with a full working solution without skipping a meal.
@bouzie8000
@bouzie8000 4 ай бұрын
I agree tbh@@zweitekonto9654
@rafael84
@rafael84 4 ай бұрын
Javascript version: function mostBooked(n, meetings) { const available = new MinPriorityQueue({ compare: (a, b) => a - b }); for (let i = 0; i < n; i++) available.enqueue(i); const used = new MinPriorityQueue({ compare: (a, b) => a[0] - b[0] || a[1] - b[1] }); const count = new Array(n).fill(0); meetings.sort((a, b) => a[0] - b[0]); meetings.forEach(([start, end]) => { while (used.size() > 0 && start >= used.front()[0]) { const [, room] = used.dequeue(); available.enqueue(room); } if (available.size() > 0) { const room = available.dequeue(); used.enqueue([end, room]); count[room] += 1; } else { const [earliestEnd, room] = used.dequeue(); used.enqueue([earliestEnd + (end - start), room]); count[room] += 1; } }); return count.indexOf(Math.max(...count)); }
@yang5843
@yang5843 4 ай бұрын
My boilerplatey Java solution, beats 23% class Solution { public int mostBooked(int n, int[][] meetings) { Map map = new HashMap(); Queue queue3 = new PriorityQueue( (a,b) -> a.getValue() == b.getValue() ? a.getKey() - b.getKey() : b.getValue() - a.getValue()); Arrays.sort(meetings,(a,b)->a[0]==b[0]?a[1]-b[1]:a[0]-b[0]); Queue queue1 = new PriorityQueue( (a,b) -> a[0]==b[0]?a[1]-b[1]: a[0] - b[0] ); Queue queue2 = new PriorityQueue(); for (int i=0;i
@justsurajp
@justsurajp 4 ай бұрын
the c++ version, with the "long long"s is a nuisance 🥲
Find All People With Secret - Leetcode 2092 - Python
14:35
NeetCodeIO
Рет қаралды 13 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 298 М.
Must-have gadget for every toilet! 🤩 #gadget
00:27
GiGaZoom
Рет қаралды 12 МЛН
Неприятная Встреча На Мосту - Полярная звезда #shorts
00:59
Полярная звезда - Kuzey Yıldızı
Рет қаралды 7 МЛН
MEGA BOXES ARE BACK!!!
08:53
Brawl Stars
Рет қаралды 35 МЛН
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 119 М.
2402. Meeting Rooms III | Sorting | Heap(Priority Queue) | Hard 🥶
39:38
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 221 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 612 М.
Reveal Cards In Increasing Order - Leetcode 950 - Python
11:14
NeetCodeIO
Рет қаралды 14 М.
Software Engineering Job Interview - Full Mock Interview
1:14:29
freeCodeCamp.org
Рет қаралды 1,3 МЛН
Arithmetic Slices II - Leetcode 446 - Python
21:19
NeetCodeIO
Рет қаралды 16 М.
MEETING ROOMS III | LEETCODE # 2402 | PYTHON HEAP SOLUTION
18:40
Cracking FAANG
Рет қаралды 6 М.
Detonate the Maximum Bombs - Leetcode 2101 - Python
11:20
NeetCodeIO
Рет қаралды 12 М.