Meeting Rooms III - Leetcode 2402 - Python

  Рет қаралды 19,374

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

Пікірлер: 43
@NeetCodeIO
@NeetCodeIO 5 ай бұрын
Sorry I'm a little late today, but better late than never! 🚀🚀
@satyamjha68
@satyamjha68 5 ай бұрын
No problem! Love your leetcode content as always!
@AmrElmohtaseb
@AmrElmohtaseb 5 ай бұрын
Thank you!! This is the video I wait for every day.
@aseshshrestha8012
@aseshshrestha8012 5 ай бұрын
Why did you stop posting in your another channel? Why another channel?
@SanketBhat7
@SanketBhat7 5 ай бұрын
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 5 ай бұрын
fwiw my java solution beats 23%, I posted the code as a comment to this video
@SairamDasari2000
@SairamDasari2000 5 ай бұрын
I thought my streak is going to end , thanks mate ❤❤
@user-jf7xb1lb2z
@user-jf7xb1lb2z 5 ай бұрын
Bro you are a lifesaver, there was absolutely no way I could have solved this on my own.
@aniketpatel8655
@aniketpatel8655 5 ай бұрын
You explained things so easily! Thank you, dude.
@NH-hq7ly
@NH-hq7ly 5 ай бұрын
Thanks for the video. My level is too low to solve this hard question. I'm just here to learn
@hoyinli7462
@hoyinli7462 5 ай бұрын
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!
@nicolasguillenc
@nicolasguillenc 5 ай бұрын
This one was rough, thanks man!
@razataggarwal7365
@razataggarwal7365 5 ай бұрын
Same thought process ! 👌
@shashwatkumar3079
@shashwatkumar3079 5 ай бұрын
I figured out what I needed to do but cant't figure out the approach of using two heaps. Good question.
@sherloccode6272
@sherloccode6272 5 ай бұрын
Love this explanation
@tarunmali6228
@tarunmali6228 3 ай бұрын
Hi, when this problem will be added to the neecode website list?
@trueArcticFox
@trueArcticFox 5 ай бұрын
Thanks!
@chaitanyasharma6270
@chaitanyasharma6270 5 ай бұрын
explain meeting rooms 2 with priority queue as well
@gokukakarot6323
@gokukakarot6323 10 күн бұрын
In the heap, is it possible to store the difference between two meetings (end,start, meeting_idx) ? Re: Naaah ignore
@hangchen
@hangchen 4 ай бұрын
7 days ago, just about time for me!
@vivekragireddy6941
@vivekragireddy6941 5 ай бұрын
can anyone post the c++ version of code for this?
@iamabominable7462
@iamabominable7462 5 ай бұрын
Never been here this early lol Love your content 😄
@NeetCodeIO
@NeetCodeIO 5 ай бұрын
ty :)
@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.
@WatchTower71
@WatchTower71 5 ай бұрын
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.
@Moch117
@Moch117 5 ай бұрын
You solved without hints ?
@sophiophile
@sophiophile 5 ай бұрын
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 5 ай бұрын
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 5 ай бұрын
@@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
@JourdanOoi-wp2lh
@JourdanOoi-wp2lh Ай бұрын
this solution no longer working for anyone else?
@synthesiakin2543
@synthesiakin2543 5 ай бұрын
What do you use to draw on the screen?
@NeetCodeIO
@NeetCodeIO 5 ай бұрын
paint 3d and a mouse
@yaswanthkosuru
@yaswanthkosuru 5 ай бұрын
​@@NeetCodeIOare u joking 😅
@navaneethku
@navaneethku 5 ай бұрын
I don't think he is joking@@yaswanthkosuru
@electricindro2236
@electricindro2236 5 ай бұрын
Brilliant!
@alieeldeenahmed2278
@alieeldeenahmed2278 5 ай бұрын
I reach test cases 69/82 I give up 😅😅
@bouzie8000
@bouzie8000 5 ай бұрын
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 5 ай бұрын
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 5 ай бұрын
I agree tbh@@zweitekonto9654
@rafael84
@rafael84 5 ай бұрын
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 5 ай бұрын
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 5 ай бұрын
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
Рет қаралды 353 М.
Best father #shorts by Secret Vlog
00:18
Secret Vlog
Рет қаралды 22 МЛН
路飞被小孩吓到了#海贼王#路飞
00:41
路飞与唐舞桐
Рет қаралды 77 МЛН
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 141 М.
Meeting Rooms II - Leetcode 253 - Python
11:46
NeetCode
Рет қаралды 122 М.
K Inverse Pairs Array - Leetcode 629 - Python
29:44
NeetCodeIO
Рет қаралды 15 М.
Furthest Building You Can Reach - Leetcode 1642 - Python
11:08
NeetCodeIO
Рет қаралды 15 М.
2402. Meeting Rooms III | Sorting | Heap(Priority Queue) | Hard 🥶
39:38
The Algorithm Behind Spell Checkers
13:02
b001
Рет қаралды 408 М.
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 259 М.
Out of Boundary Paths - Leetcode 576 - Python
18:20
NeetCodeIO
Рет қаралды 15 М.
Maximum Profit in Job Scheduling - Leetcode 1235 - Python
14:45
NeetCodeIO
Рет қаралды 29 М.
Greatest Common Divisor Traversal - Leetcode 2709 - Python
24:30
Best father #shorts by Secret Vlog
00:18
Secret Vlog
Рет қаралды 22 МЛН