Divide Intervals Into Minimum Number of Groups - Leetcode 2406 - Python

preview_player
Показать описание


0:00 - Read the problem
0:30 - Drawing Explanation
8:58 - Coding Explanation

leetcode 2406

#neetcode #leetcode #python
Рекомендации по теме
Комментарии
Автор

Man, That sliding line at 3:24 was so good. You're a legend of a teacher for explaining it that way! Thank you so much Navdeep.

aadil
Автор

Even though I could do this question on my own, I clicked on Neetcode video anyway, because I wanted to see your approach too. The way you explain things and make everything intuitive, it just makes you feel confident. I watch your explanation and code it up myself! Thanks Neetcode. I'm so happy that I'm getting a genuine interest in this stuff, and you absolutely helped me here.

priyadarshiniroy
Автор

I respect the dedication and hard work this man puts for the daily problems. Simply just take a bow.

sahanalakshmipathy
Автор

Sliding rule made this so clear. However, I am banging my head against the wall trying to understand how the start and end times are separated, then sorted separately... and it works. Thanks for putting in the effort to do these videos.

seanjcan
Автор

I love the way you explain things. I have recently started doing leetcode and whenever I get stuck I look at your solution and explanation, and then do it myself while commenting in my code whatever new I learned. Thank you so much for your hardwork <3

anubhav
Автор

that sliding line was some really good intuition. i can see how it can be useful for all interval problems.

_PranavDesai
Автор

Such a great explanation. That ruler thing is excellent. Day by day the quality of content increases.

karthi
Автор

i couldn't understand why did we sort start and end individually?

vatsalshah
Автор

I actually solved it by sorting the array first then creating a min heap (ending time of interval),
Now if the leaving time is greater than the next arrival time we get an intersection and we push it into queue, if it is not we simply pop the top of queue and then push the latest leaving time again in both cases.
Return queue's size.

It was accepted and inefficient, but this is what i learned from you by watching your yesterday's solution.
So thankyou..❤️

chootajezu
Автор

dawg didn't this problem just come out how do you already have a video on it

sarmohanty
Автор

Great explanation! I was having trouble understand why/how the sorting solution worked.
But this video made it really easy to finally understand it! Great video.

GustjcDev
Автор

@NeetCodeIO Is this same as line sweep algo given in leetcode editorial??

manojvn
Автор

You can move line 19 to line 17, then it only updates res (and call max) when you are lengthening the window.

ramennudeln
Автор

Wow excellent intutation. I solved it using heap but the solution is not as efficient.

freecourseplatformenglish
Автор

Finally I see the results. Managed to solve it using heap

yaroslav
Автор

Interesting that people skip the explanation, some times is the main thing I watch before I try to code it my self. ( pausing the video in between)

RolopIsHere
Автор

What about proving that you never need more groups than the maximum number of intersections?

finemechanic
Автор

I noticed it was similar to meeting room 2 too, used the exact same code and solved it lmao

finnar
Автор

Good Morning...Today is day 7 of 100 days of code

karnikhil
Автор

I first tried greedy, but it doesn't work lol

guyguysir