Meeting Rooms III - Leetcode 2402 - Python

  Рет қаралды 22,615

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 44
@NeetCodeIO
@NeetCodeIO 9 ай бұрын
Sorry I'm a little late today, but better late than never! 🚀🚀
@satyamjha68
@satyamjha68 9 ай бұрын
No problem! Love your leetcode content as always!
@AmrElmohtaseb
@AmrElmohtaseb 9 ай бұрын
Thank you!! This is the video I wait for every day.
@aseshshrestha8012
@aseshshrestha8012 9 ай бұрын
Why did you stop posting in your another channel? Why another channel?
@SanketBhat7
@SanketBhat7 9 ай бұрын
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 9 ай бұрын
fwiw my java solution beats 23%, I posted the code as a comment to this video
@VaibhavSandhir
@VaibhavSandhir 9 ай бұрын
Bro you are a lifesaver, there was absolutely no way I could have solved this on my own.
@SairamDasari2000
@SairamDasari2000 9 ай бұрын
I thought my streak is going to end , thanks mate ❤❤
@quirkyquester
@quirkyquester 27 күн бұрын
the solution is so elegant here, thank you so much! Eye opening!
@hoyinli7462
@hoyinli7462 9 ай бұрын
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!
@NH-hq7ly
@NH-hq7ly 9 ай бұрын
Thanks for the video. My level is too low to solve this hard question. I'm just here to learn
@shashwatkumar3079
@shashwatkumar3079 9 ай бұрын
I figured out what I needed to do but cant't figure out the approach of using two heaps. Good question.
@aniketpatel8655
@aniketpatel8655 9 ай бұрын
You explained things so easily! Thank you, dude.
@iamabominable7462
@iamabominable7462 9 ай бұрын
Never been here this early lol Love your content 😄
@NeetCodeIO
@NeetCodeIO 9 ай бұрын
ty :)
@razataggarwal7365
@razataggarwal7365 9 ай бұрын
Same thought process ! 👌
@sherloccode6272
@sherloccode6272 9 ай бұрын
Love this explanation
@nicolasguillenc
@nicolasguillenc 9 ай бұрын
This one was rough, thanks man!
@chaitanyasharma6270
@chaitanyasharma6270 9 ай бұрын
explain meeting rooms 2 with priority queue as well
@sophiophile
@sophiophile 9 ай бұрын
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 9 ай бұрын
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 9 ай бұрын
@@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
@suvajitchakrabarty
@suvajitchakrabarty 8 ай бұрын
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 8 ай бұрын
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.
@hangchen
@hangchen 9 ай бұрын
7 days ago, just about time for me!
@gokukakarot6323
@gokukakarot6323 4 ай бұрын
In the heap, is it possible to store the difference between two meetings (end,start, meeting_idx) ? Re: Naaah ignore
@WatchTower71
@WatchTower71 9 ай бұрын
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.
@tarunmali6228
@tarunmali6228 7 ай бұрын
Hi, when this problem will be added to the neecode website list?
@trueArcticFox
@trueArcticFox 9 ай бұрын
Thanks!
@JourdanOoi-wp2lh
@JourdanOoi-wp2lh 6 ай бұрын
this solution no longer working for anyone else?
@synthesiakin2543
@synthesiakin2543 9 ай бұрын
What do you use to draw on the screen?
@NeetCodeIO
@NeetCodeIO 9 ай бұрын
paint 3d and a mouse
@yaswanthkosuru
@yaswanthkosuru 9 ай бұрын
​@@NeetCodeIOare u joking 😅
@navaneethku
@navaneethku 9 ай бұрын
I don't think he is joking@@yaswanthkosuru
@Moch117
@Moch117 9 ай бұрын
You solved without hints ?
@vivekragireddy6941
@vivekragireddy6941 9 ай бұрын
can anyone post the c++ version of code for this?
@rafael84
@rafael84 9 ай бұрын
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)); }
@bouzie8000
@bouzie8000 9 ай бұрын
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 9 ай бұрын
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 9 ай бұрын
I agree tbh@@zweitekonto9654
@alieeldeenahmed2278
@alieeldeenahmed2278 9 ай бұрын
I reach test cases 69/82 I give up 😅😅
@electricindro2236
@electricindro2236 9 ай бұрын
Brilliant!
@yang5843
@yang5843 9 ай бұрын
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 9 ай бұрын
the c++ version, with the "long long"s is a nuisance 🥲
Find All People With Secret - Leetcode 2092 - Python
14:35
NeetCodeIO
Рет қаралды 14 М.
Subarrays with K Different Integers - Leetcode 992 - Python
17:31
Creative Justice at the Checkout: Bananas and Eggs Showdown #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 6 МЛН
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 138 МЛН
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 60 МЛН
Мама у нас строгая
00:20
VAVAN
Рет қаралды 11 МЛН
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 695 М.
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 150 М.
LeetCode 68. Text Justification (Java)
17:18
Syntax
Рет қаралды 39
Minimum Falling Path Sum - Leetcode 931 - Python
14:02
NeetCodeIO
Рет қаралды 14 М.
MEETING ROOMS III | LEETCODE # 2402 | PYTHON HEAP SOLUTION
18:40
Cracking FAANG
Рет қаралды 6 М.
Maximum Profit in Job Scheduling - Leetcode 1235 - Python
14:45
NeetCodeIO
Рет қаралды 35 М.
Meeting Rooms II - Leetcode 253 - Python
11:46
NeetCode
Рет қаралды 149 М.
UBER'S #1 INTERVIEW QUESTION | BUS ROUTES | PYTHON BFS SOLUTION
18:03
Cracking FAANG
Рет қаралды 4,4 М.
The LeetCode Fallacy
6:08
NeetCode
Рет қаралды 576 М.
Creative Justice at the Checkout: Bananas and Eggs Showdown #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 6 МЛН