Arrays | Leetcode 659 | Split Array Into Consecutive Subsequences

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

Nideesh Terapalli

Nideesh Terapalli

Күн бұрын

Пікірлер: 98
@Gurpreetkaur-ws4fv
@Gurpreetkaur-ws4fv 4 жыл бұрын
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.
@c9bd415
@c9bd415 5 жыл бұрын
Thank you, couldn't understand those descriptions on leetcode..
@NideeshTerapalli
@NideeshTerapalli 5 жыл бұрын
Haha you're welcome
@bakguff
@bakguff 2 жыл бұрын
Dude, great explanation. I was really confused by other explanations of this problem but this helped out alot!
@ptitm2667
@ptitm2667 3 жыл бұрын
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
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Do you have a contact? I want to talk to you
@sparshsharma6068
@sparshsharma6068 2 жыл бұрын
Halfway through the video and I got an AC on leetcode just by understanding the way you explained the intuition! Thanks a lot
@ramanahlawat398
@ramanahlawat398 2 жыл бұрын
thanks man!! appreciate the help nice explanation too!!
@harshtyagi700
@harshtyagi700 2 жыл бұрын
You nailed the explaination part. Thanks!!
@arthamsreenivas8858
@arthamsreenivas8858 4 жыл бұрын
Thank you brother, leetcode solution is very hard to understand, keep going on!
@NideeshTerapalli
@NideeshTerapalli 4 жыл бұрын
Thanks Artham
@thomashirtz
@thomashirtz 3 жыл бұрын
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 👌
@NideeshTerapalli
@NideeshTerapalli 3 жыл бұрын
Thanks Thomas, I'm always getting a tiny bit better every day
@nopecharon
@nopecharon 2 жыл бұрын
What a beast explanation. You earned a new sub
@learnninspire7984
@learnninspire7984 2 жыл бұрын
great explanation bro!
@fahadabdullah687
@fahadabdullah687 2 жыл бұрын
Greatly explained. It's todays daily challenge on leetcode. 19 aug 2022.
@nagalakshmi1385
@nagalakshmi1385 4 жыл бұрын
great video as always! The best way to explain the intuition behind solving the problem, you always do best among all. Thanks a lot !
@saumya1singh
@saumya1singh 4 жыл бұрын
Superb Nideesh!
@manasdeora4601
@manasdeora4601 2 жыл бұрын
Loved the explanation. Could not think of this approach.
@AYJ959
@AYJ959 Жыл бұрын
Thanks a lot dude , you explained it very well!
@diaoyuanhuzhenhuiqi
@diaoyuanhuzhenhuiqi Жыл бұрын
really the best explaination i seen
@kewtomrao
@kewtomrao 2 жыл бұрын
Thats an amazing explanation!
@anderswb
@anderswb 3 жыл бұрын
This solution is tricky to get your head around at first but this is a great and concise explanation.
@manojborugadda9212
@manojborugadda9212 2 жыл бұрын
Excellent explanation Nideesh anna😀😀🙌
@prabhatkumar-eg2rg
@prabhatkumar-eg2rg 3 жыл бұрын
Good stuff Nideesh. Keep cracking on.
@NideeshTerapalli
@NideeshTerapalli 3 жыл бұрын
Thanks Prabhat
@shenth27
@shenth27 4 жыл бұрын
Excellent explanation with always sticking to the point.
@vishweshpujari2584
@vishweshpujari2584 2 жыл бұрын
Best explanation for this problem. Thanks!
@prempeacefulchannel
@prempeacefulchannel 2 жыл бұрын
You explained it very clearly. Thanks a lot bro!
@rakshith3547
@rakshith3547 4 жыл бұрын
by far the best explanation for this problem.. keep up the good work bro
@bhargavamarpina8294
@bhargavamarpina8294 4 жыл бұрын
Nice Explanation.
@swapanshridhar1
@swapanshridhar1 4 жыл бұрын
Perfect. Very helpful explanation. Thanks!
@ChanChan-pg4wu
@ChanChan-pg4wu 2 жыл бұрын
Nice Work!
@quirkyquester
@quirkyquester 2 жыл бұрын
this is a fire video brother! Thank you! brilliant!
@koushikkumar5156
@koushikkumar5156 2 жыл бұрын
Nice explanation
@rajarshisarkar5488
@rajarshisarkar5488 4 жыл бұрын
Very clear explanation! Thanks.
@sachinwathore3773
@sachinwathore3773 4 жыл бұрын
Thanks a lot Nideesh for an awesome explanation. I found it very helpful !
@nishantdhamija2880
@nishantdhamija2880 2 жыл бұрын
that was really good
@tanmaypahuja206
@tanmaypahuja206 4 жыл бұрын
Amazing explanation! Thanks a lot!
@akhilchakravarthy
@akhilchakravarthy 4 жыл бұрын
Good job dude
@toekneema
@toekneema 3 жыл бұрын
thank you! great walkthrough!
@mashab9129
@mashab9129 3 жыл бұрын
brilliant solution. thanks for sharing.
@thegt
@thegt 4 жыл бұрын
Very nice explanation! Great job man!
@nikhil.pandey
@nikhil.pandey 2 жыл бұрын
smooth
@kollivenkatamadhukar5059
@kollivenkatamadhukar5059 4 жыл бұрын
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....
@Cloud-577
@Cloud-577 2 жыл бұрын
thank you :) you are great at explaining
@rajatbudania6181
@rajatbudania6181 4 жыл бұрын
Plz upload more videos, these are really helpful mate!
@pukhrajsoni4020
@pukhrajsoni4020 2 жыл бұрын
Excellent explanation
@labi9500
@labi9500 2 жыл бұрын
thanks!
@navidr2811
@navidr2811 4 жыл бұрын
great job explaining it man!
@shantanukshire79
@shantanukshire79 4 жыл бұрын
Super solution !
@chuyi8664
@chuyi8664 4 жыл бұрын
Thank you! it is really helpful
@saicharan8675
@saicharan8675 4 жыл бұрын
Super cool thanks for sharing
@_ADITIKAJALE
@_ADITIKAJALE 3 жыл бұрын
best explanation ! thanks :))
@guolongli6667
@guolongli6667 4 жыл бұрын
NICE IDEA AND WONDERFUL EXPLANATION! you help me solve the problem :>
@iriswei3018
@iriswei3018 4 жыл бұрын
very helpful!
@NideeshTerapalli
@NideeshTerapalli 4 жыл бұрын
You're welcome
@yashbansal1520
@yashbansal1520 4 жыл бұрын
Great explanation
@DSUNDAR_
@DSUNDAR_ 2 ай бұрын
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
@RagazzoKZ
@RagazzoKZ 5 жыл бұрын
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 } }
@NideeshTerapalli
@NideeshTerapalli 5 жыл бұрын
Interesting, thanks for sharing this. I actually did not explore a solution with a Priority Queue, appreciate going over it.
@sumitkumar-ps9rl
@sumitkumar-ps9rl 4 жыл бұрын
HI Nideesh, It was really helpful. I used multiset from c++ in place of a map. Thank You.
@NideeshTerapalli
@NideeshTerapalli 4 жыл бұрын
Happy to help
@kaichenghu3826
@kaichenghu3826 4 жыл бұрын
Thanks for your explanation
@NideeshTerapalli
@NideeshTerapalli 4 жыл бұрын
You're welcome
@TrenBlack
@TrenBlack 5 жыл бұрын
Have you ever done Candy Crush? It is leetcode 723... (You might need leetcode premium to access it)
@NideeshTerapalli
@NideeshTerapalli 5 жыл бұрын
Hey Tren, I won't be able to make videos on leetcode premium questions since they are private on their website. Sorry about that!
@rajatbudania6181
@rajatbudania6181 4 жыл бұрын
Very Nice Explanation! )-
@NideeshTerapalli
@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)
@RagazzoKZ
@RagazzoKZ 5 жыл бұрын
Wow, new videos!
@NideeshTerapalli
@NideeshTerapalli 5 жыл бұрын
Yup, sorry for the delay. I remember you requested this one, hope it helps!
@gurpreetchawla2066
@gurpreetchawla2066 3 жыл бұрын
Hypothetical Map shows - ( key , demand of a number ) . Incase someone's confused what hypothetical map do.
@sarthakchoudhary811
@sarthakchoudhary811 4 жыл бұрын
very nice.
@ajr1791ze
@ajr1791ze 4 жыл бұрын
amazing.
@sabbispeak
@sabbispeak 4 жыл бұрын
nice expaalanaation mate
@jaesungj
@jaesungj 4 жыл бұрын
While the explanation was really good do you have any good resource on the steps toward how we eventually came up with this algorithm?
@NideeshTerapalli
@NideeshTerapalli 4 жыл бұрын
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
@algorithmimplementer415
@algorithmimplementer415 4 жыл бұрын
Could you group this kind of questions that are a bit tricky and relevant to crack big tech company interview? Thanks!
@NideeshTerapalli
@NideeshTerapalli 4 жыл бұрын
Good idea
@chamcham3806
@chamcham3806 4 жыл бұрын
Why are we trying to append to the hypothetical map first (preferring it over starting a new sequence from the current element) ?
@NideeshTerapalli
@NideeshTerapalli 4 жыл бұрын
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
@chamcham3806
@chamcham3806 4 жыл бұрын
@@NideeshTerapalli Thanks for your quick reply. Got it cleared.
@HOW--2
@HOW--2 2 жыл бұрын
What does hypothetical map mean bro ?
@akshatjain7742
@akshatjain7742 4 жыл бұрын
Why do we need to keep numbers with value 0 in the Hmap? Those are the numbers that can no longer be accepted, right?
@NideeshTerapalli
@NideeshTerapalli 4 жыл бұрын
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
@bismeetsingh352
@bismeetsingh352 4 жыл бұрын
Python solution: leetcode.com/problems/split-array-into-consecutive-subsequences/discuss/811017/Hypothetical-Map!!
@AbhijeetNayak-connect
@AbhijeetNayak-connect 4 жыл бұрын
Bad description of the problem, along with a +ve case, also explain a -ve input
@cutsandstonebetablocksumo9891
@cutsandstonebetablocksumo9891 2 жыл бұрын
5:28 does anyone want me?
@iriswei3018
@iriswei3018 4 жыл бұрын
btw, you are cute!
@NideeshTerapalli
@NideeshTerapalli 4 жыл бұрын
Haha, i'm flattered thank you
@karun4663
@karun4663 5 жыл бұрын
plz make oop videos
@NideeshTerapalli
@NideeshTerapalli 5 жыл бұрын
Hi Karun, yeah sure. I'm focusing on algos at the moment, then sys design. Eventually I will cover oop too
@shubham28921
@shubham28921 4 жыл бұрын
1.25x
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Do you have a contact? I want to talk to you
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Do you have a contact? I want to talk to you
@NideeshTerapalli
@NideeshTerapalli 5 жыл бұрын
Back To Back SWE hi you can email me at nterapalli1 @ [gmail . com ]
Verify Alien Dictionary | Leetcode 953 | Arrays
14:15
Nideesh Terapalli
Рет қаралды 5 М.
(Remade) Subsets I | Leetcode 78 | Backtracking
9:41
Nideesh Terapalli
Рет қаралды 10 М.
АЗАРТНИК 4 |СЕЗОН 1 Серия
40:47
Inter Production
Рет қаралды 1,3 МЛН
Electric Flying Bird with Hanging Wire Automatic for Ceiling Parrot
00:15
Magic or …? 😱 reveal video on profile 🫢
00:14
Andrey Grechka
Рет қаралды 61 МЛН
POV: Your kids ask to play the claw machine
00:20
Hungry FAM
Рет қаралды 9 МЛН
Leetcode 29 - Bit Manipulation | Divide Two Integers
9:32
Nideesh Terapalli
Рет қаралды 61 М.
Find The Longest Increasing Subsequence - Dynamic Programming Fundamentals
19:21
Easy Google Coding Interview With Ben Awad
28:00
Clément Mihailescu
Рет қаралды 1 МЛН
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Binary Search : Median of two sorted arrays of different sizes.
24:48
Tushar Roy - Coding Made Simple
Рет қаралды 544 М.
(Remade) Longest Univalue Path | Binary Tree | Leetcode 687
6:04
Nideesh Terapalli
Рет қаралды 5 М.
Google Coding Interview With A Competitive Programmer
54:17
Clément Mihailescu
Рет қаралды 2,5 МЛН
Minimum Domino Rotations for Equal Row
12:34
Kevin Naughton Jr.
Рет қаралды 43 М.
Leetcode 659. Split Array into Consecutive Subsequences
36:29
АЗАРТНИК 4 |СЕЗОН 1 Серия
40:47
Inter Production
Рет қаралды 1,3 МЛН