This is the first video among all, which could clearly explain to me the logic of the greedy approach used here and get convinced with the intuition. 1. Though i could not find any resources on the internet which could help me understand the process - How can I come up with such intuition. 2. But at least, this video was really helpful to get convinced for the algorithm. and then I was able to write a correct code my self. Many Thanks.
@bakguff2 жыл бұрын
Dude, great explanation. I was really confused by other explanations of this problem but this helped out alot!
@c9bd4155 жыл бұрын
Thank you, couldn't understand those descriptions on leetcode..
@NideeshTerapalli5 жыл бұрын
Haha you're welcome
@ptitm26673 жыл бұрын
great explanation! very clear and easy to understand! I'm Chinese so I usually watch videos explained in Chinese bc it's easy to understand, but I found yours is much clearer! Thank you
@BackToBackSWE5 жыл бұрын
Do you have a contact? I want to talk to you
@sparshsharma60683 жыл бұрын
Halfway through the video and I got an AC on leetcode just by understanding the way you explained the intuition! Thanks a lot
@thomashirtz4 жыл бұрын
Seriously, nice job I saw a video of you some time ago, it's cool to see your evolution, and see you making them cleaner and better every time 👌
@NideeshTerapalli4 жыл бұрын
Thanks Thomas, I'm always getting a tiny bit better every day
@saumya1singh4 жыл бұрын
Superb Nideesh!
@harshtyagi7002 жыл бұрын
You nailed the explaination part. Thanks!!
@manasdeora46012 жыл бұрын
Loved the explanation. Could not think of this approach.
@asishcodes2 жыл бұрын
What a beast explanation. You earned a new sub
@fahadabdullah6872 жыл бұрын
Greatly explained. It's todays daily challenge on leetcode. 19 aug 2022.
@prabhatkumar-eg2rg4 жыл бұрын
Good stuff Nideesh. Keep cracking on.
@NideeshTerapalli4 жыл бұрын
Thanks Prabhat
@ramanahlawat3982 жыл бұрын
thanks man!! appreciate the help nice explanation too!!
@nagalakshmi13854 жыл бұрын
great video as always! The best way to explain the intuition behind solving the problem, you always do best among all. Thanks a lot !
@arthamsreenivas88584 жыл бұрын
Thank you brother, leetcode solution is very hard to understand, keep going on!
@NideeshTerapalli4 жыл бұрын
Thanks Artham
@AYJ9592 жыл бұрын
Thanks a lot dude , you explained it very well!
@kollivenkatamadhukar50594 жыл бұрын
Can you please explain your taught process how you arrived at the solution, I mean how did you get to know you have to use an hypothetical map....
@NideeshTerapalli Жыл бұрын
Hey there! Just wanted to let you know that some of the links in this comment are affiliate links, which means that if you make a purchase through them, I may earn a small commission. Don't worry though, it doesn't cost you anything extra and it helps support this channel so I can continue to make more videos for you. Thank you so much for your support, and as always, all opinions are my own! Start getting great at system design: bytebytego.com?fpr=nideesh (affiliate link) Handpicked Algorithms and Data Structures for Interview To Save Time: interviewpen.com/?via=nideesh (affiliate link) Fast track to becoming a knowledgeable SWE www.educative.io/unlimited?aff=K1z6 (affiliate link)
@premraja552 жыл бұрын
You explained it very clearly. Thanks a lot bro!
@vishweshpujari25842 жыл бұрын
Best explanation for this problem. Thanks!
@diaoyuanhuzhenhuiqi2 жыл бұрын
really the best explaination i seen
@manojborugadda92122 жыл бұрын
Excellent explanation Nideesh anna😀😀🙌
@rakshith35474 жыл бұрын
by far the best explanation for this problem.. keep up the good work bro
@learnninspire79842 жыл бұрын
great explanation bro!
@anderswb3 жыл бұрын
This solution is tricky to get your head around at first but this is a great and concise explanation.
@quirkyquester3 жыл бұрын
this is a fire video brother! Thank you! brilliant!
@shenth274 жыл бұрын
Excellent explanation with always sticking to the point.
@kewtomrao2 жыл бұрын
Thats an amazing explanation!
@sachinwathore37734 жыл бұрын
Thanks a lot Nideesh for an awesome explanation. I found it very helpful !
@rajarshisarkar54884 жыл бұрын
Very clear explanation! Thanks.
@swapanshridhar14 жыл бұрын
Perfect. Very helpful explanation. Thanks!
@koushikkumar51562 жыл бұрын
Nice explanation
@mashab91293 жыл бұрын
brilliant solution. thanks for sharing.
@pukhrajsoni40202 жыл бұрын
Excellent explanation
@TrenBlack5 жыл бұрын
Have you ever done Candy Crush? It is leetcode 723... (You might need leetcode premium to access it)
@NideeshTerapalli5 жыл бұрын
Hey Tren, I won't be able to make videos on leetcode premium questions since they are private on their website. Sorry about that!
@thegt4 жыл бұрын
Very nice explanation! Great job man!
@algorithmimplementer4154 жыл бұрын
Could you group this kind of questions that are a bit tricky and relevant to crack big tech company interview? Thanks!
@NideeshTerapalli4 жыл бұрын
Good idea
@chamcham38065 жыл бұрын
Why are we trying to append to the hypothetical map first (preferring it over starting a new sequence from the current element) ?
@NideeshTerapalli5 жыл бұрын
Which line in the code are you referring to? Or you could tell me which part of the video you had in mind. But if you are asking in general why does an element try to append itself to an existing sequence instead of starting a new one, the reasons are as follows: 1) This is a greedy approach 2) If a number can join a subsequence that is already generated then it will do so because the algorithm's job is to identify (true/false) whether or not we can generate valid subsequences. If a number is always trying to start a new subsequence then it might not have all the elements in the array/frequency map to create a valid subsequence. That's why a number will prefer to join a subsequence if it can and in doing so create a new "hypothetical" spot for the next integer which may come from anywhere in the array. Feel free to ask more questions
@chamcham38065 жыл бұрын
@@NideeshTerapalli Thanks for your quick reply. Got it cleared.
@rajatbudania61814 жыл бұрын
Plz upload more videos, these are really helpful mate!
@bhargavam52344 жыл бұрын
Nice Explanation.
@Cloud-5772 жыл бұрын
thank you :) you are great at explaining
@tanmaypahuja2064 жыл бұрын
Amazing explanation! Thanks a lot!
@yashbansal15204 жыл бұрын
Great explanation
@ChanChan-pg4wu2 жыл бұрын
Nice Work!
@toekneema4 жыл бұрын
thank you! great walkthrough!
@sumitkumar-ps9rl5 жыл бұрын
HI Nideesh, It was really helpful. I used multiset from c++ in place of a map. Thank You.
@NideeshTerapalli5 жыл бұрын
Happy to help
@_ADITIKAJALE3 жыл бұрын
best explanation ! thanks :))
@nishantdhamija28802 жыл бұрын
that was really good
@shantanukshire794 жыл бұрын
Super solution !
@saicharan86754 жыл бұрын
Super cool thanks for sharing
@guolongli66674 жыл бұрын
NICE IDEA AND WONDERFUL EXPLANATION! you help me solve the problem :>
@navidr28114 жыл бұрын
great job explaining it man!
@jaesungj4 жыл бұрын
While the explanation was really good do you have any good resource on the steps toward how we eventually came up with this algorithm?
@NideeshTerapalli4 жыл бұрын
Hi JJ, sorry I don't. I gave credit to the original post in the video description. Looks like "greedy" algos don't have the same templates as other questions like say backtracking. Will share it if I find though
@akhilchakravarthy4 жыл бұрын
Good job dude
@akshatjain77425 жыл бұрын
Why do we need to keep numbers with value 0 in the Hmap? Those are the numbers that can no longer be accepted, right?
@NideeshTerapalli5 жыл бұрын
Hmap is actually just hypothetical k-v storage. We might encounter a number later in the array which belong there. Feel free to ask more clarifying questions if i didn't explain clearly
@HOW--22 жыл бұрын
What does hypothetical map mean bro ?
@chuyi86644 жыл бұрын
Thank you! it is really helpful
@rajatbudania61814 жыл бұрын
Very Nice Explanation! )-
@kaichenghu38265 жыл бұрын
Thanks for your explanation
@NideeshTerapalli5 жыл бұрын
You're welcome
@RagazzoKZ5 жыл бұрын
I think it would be interesting to consider edge cases. What if you have two sequences expecting the same number? In this case, you should push the number into the shorter sequence. I used a priority queue for that. But it's not the best solution. const map = new Map() // storing priority queues of sequences, key is the expecting number (i.e. next number in sequence) for (let num of nums) { let prevPq = map.get(num - 1) let subseq if (!prevPq) { subseq = new Subseq(num) } else { subseq = prevPq.pop() subseq.addLast(num) if (prevPq.isEmpty()) { map.delete(num - 1) } } let nextPq = map.get(num) if (!nextPq) { nextPq = new PriorityQueue() } nextPq.push(subseq) map.set(num, nextPq) } for (let [key, pq] of map) { for (let subseq of pq._heap) { if (!subseq.isValid()) { return false } } } return true my Subseq class: class Subseq { constructor(last) { this.last = last this.len = 1 } addLast(last) { this.last = last this.len++ } getLast() { return this.last } getLen() { return this.len } isValid() { return this.len > 2 } }
@NideeshTerapalli5 жыл бұрын
Interesting, thanks for sharing this. I actually did not explore a solution with a Priority Queue, appreciate going over it.
@gurpreetchawla20663 жыл бұрын
Hypothetical Map shows - ( key , demand of a number ) . Incase someone's confused what hypothetical map do.
@labi10092 жыл бұрын
thanks!
@nikhil.pandey3 жыл бұрын
smooth
@DSUNDAR_6 ай бұрын
In short, 3 cases : case1: can join existing group-> check anybody wants the current number by looking hypothetical map. case2: eligible to create a group case3: not eligible to create group as well cannot join any group. return false
@iriswei30185 жыл бұрын
very helpful!
@NideeshTerapalli5 жыл бұрын
You're welcome
@RagazzoKZ5 жыл бұрын
Wow, new videos!
@NideeshTerapalli5 жыл бұрын
Yup, sorry for the delay. I remember you requested this one, hope it helps!