Sorry I'm a little late today, but better late than never! 🚀🚀
@satyamjha689 ай бұрын
No problem! Love your leetcode content as always!
@AmrElmohtaseb9 ай бұрын
Thank you!! This is the video I wait for every day.
@aseshshrestha80129 ай бұрын
Why did you stop posting in your another channel? Why another channel?
@SanketBhat79 ай бұрын
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.
@yang58439 ай бұрын
fwiw my java solution beats 23%, I posted the code as a comment to this video
@VaibhavSandhir9 ай бұрын
Bro you are a lifesaver, there was absolutely no way I could have solved this on my own.
@SairamDasari20009 ай бұрын
I thought my streak is going to end , thanks mate ❤❤
@quirkyquester27 күн бұрын
the solution is so elegant here, thank you so much! Eye opening!
@hoyinli74629 ай бұрын
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-hq7ly9 ай бұрын
Thanks for the video. My level is too low to solve this hard question. I'm just here to learn
@shashwatkumar30799 ай бұрын
I figured out what I needed to do but cant't figure out the approach of using two heaps. Good question.
@aniketpatel86559 ай бұрын
You explained things so easily! Thank you, dude.
@iamabominable74629 ай бұрын
Never been here this early lol Love your content 😄
@NeetCodeIO9 ай бұрын
ty :)
@razataggarwal73659 ай бұрын
Same thought process ! 👌
@sherloccode62729 ай бұрын
Love this explanation
@nicolasguillenc9 ай бұрын
This one was rough, thanks man!
@chaitanyasharma62709 ай бұрын
explain meeting rooms 2 with priority queue as well
@sophiophile9 ай бұрын
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?
@NeetCodeIO9 ай бұрын
Yeah exactly, heaps are stored as lists in python. Even in languages like Java they are implemented with arrays / ArrayList under the hood
@sophiophile9 ай бұрын
@@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
@suvajitchakrabarty8 ай бұрын
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?
@suvajitchakrabarty8 ай бұрын
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.
@hangchen9 ай бұрын
7 days ago, just about time for me!
@gokukakarot63234 ай бұрын
In the heap, is it possible to store the difference between two meetings (end,start, meeting_idx) ? Re: Naaah ignore
@WatchTower719 ай бұрын
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.
@tarunmali62287 ай бұрын
Hi, when this problem will be added to the neecode website list?
@trueArcticFox9 ай бұрын
Thanks!
@JourdanOoi-wp2lh6 ай бұрын
this solution no longer working for anyone else?
@synthesiakin25439 ай бұрын
What do you use to draw on the screen?
@NeetCodeIO9 ай бұрын
paint 3d and a mouse
@yaswanthkosuru9 ай бұрын
@@NeetCodeIOare u joking 😅
@navaneethku9 ай бұрын
I don't think he is joking@@yaswanthkosuru
@Moch1179 ай бұрын
You solved without hints ?
@vivekragireddy69419 ай бұрын
can anyone post the c++ version of code for this?
@rafael849 ай бұрын
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)); }
@bouzie80009 ай бұрын
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
@zweitekonto96549 ай бұрын
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.
@bouzie80009 ай бұрын
I agree tbh@@zweitekonto9654
@alieeldeenahmed22789 ай бұрын
I reach test cases 69/82 I give up 😅😅
@electricindro22369 ай бұрын
Brilliant!
@yang58439 ай бұрын
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
@justsurajp9 ай бұрын
the c++ version, with the "long long"s is a nuisance 🥲