Remove Duplicates from Sorted List II | Live Coding with Explanation | Leetcode #82

  Рет қаралды 49,344

Algorithms Made Easy

Algorithms Made Easy

Күн бұрын

Пікірлер: 99
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 4 жыл бұрын
We hope you all are enjoying our videos!!! Don't forget to leave a comment!!! Please like the video to support us!!! Questions you might like: ✅✅✅[ Tree Data Structure ] : kzbin.info/aero/PLJtzaiEpVo2zx-rCqLMmcFEpZw1UpGWls ✅✅✅[ Graphs Data Structure ] : kzbin.info/aero/PLJtzaiEpVo2xg89cZzZCHqX03a1Vb6w7C ✅✅✅[ January Leetcoding Challenge 2021 ] : kzbin.info/aero/PLJtzaiEpVo2wCalBcRcNjXQ0C6ku3dRkn ✅✅✅[ December Leetcoding Challenge 2020 ] : kzbin.info/aero/PLJtzaiEpVo2xo8OdPZxrpybGR8FmzZpCA ✅✅✅[ November Leetcoding Challenge 2020 ] : kzbin.info/aero/PLJtzaiEpVo2yMYz5RPH6pfB0wNnwWsK7e ✅✅✅[ August Leetcoding Challenge 2020 ] : kzbin.info/aero/PLJtzaiEpVo2xu4h0gYQzvOMboclK_pZMe ✅✅✅ [ July Leetcoding Challenge 2020] : kzbin.info/aero/PLJtzaiEpVo2wrUwkvexbC-vbUqVIy7qC- ✅✅✅ [ June Leetcoding Challenge 2020 ] : kzbin.info/aero/PLJtzaiEpVo2xIfpptnCvUtKrUcod2zAKG ✅✅✅ [May Leetcoding Challenge 2020 ] : kzbin.info/aero/PLJtzaiEpVo2wRmUCq96zsUwOVD6p66K9e ✅✅✅Cracking the Coding Interview - Unique String: kzbin.info/aero/PLJtzaiEpVo2xXf4LZb3y_BopOnLC1L4mE Struggling in a question?? Leave in a comment and we will make a video!!!🙂🙂🙂
@mengyuanzhang9288
@mengyuanzhang9288 17 күн бұрын
This is literally the most vivid explanation I've ever seen. THANK YOU SOOO MUCH!! Finally understood how to remove duplicates from a sorted list. I had struggled for hours.
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 8 күн бұрын
happy to help!! Please like, share and subscribe to the channel.
@poetryiscodingdecoding7965
@poetryiscodingdecoding7965 2 жыл бұрын
Literally this is the best explanation for this question ...The way she developed the intuation and then coded ..not even found helpful on others channel and even foreigners...
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 2 жыл бұрын
Glad you enjoyed it!
@harinijeyaraman8789
@harinijeyaraman8789 3 жыл бұрын
This video has such a crisp and precise explanation at the beginning. Found this very helpful !
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Thanks ! Glad tou liked it !! Keep learning.
@badabeta6973
@badabeta6973 Жыл бұрын
this is the best explanation I found so far
@ashishshahpur7105
@ashishshahpur7105 3 жыл бұрын
This solution is good for Java as there is automatic garbage collection. In case of C++, it will run perfectly but there will be memory leaks as the memory on the heap will never get cleared. How do we approach this in that case?
@demohamnead8662
@demohamnead8662 5 ай бұрын
Free the memory before the program ends?
@ziyadauti3676
@ziyadauti3676 Жыл бұрын
Best explanation compared to all other videos on this question #82 ....🤗
@consistentthoughts826
@consistentthoughts826 4 жыл бұрын
Very good explanation I was not able to visualise like this Now I am able to solve
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 4 жыл бұрын
Thanks @Renuka Glad you liked it !! Keep learning, happy coding !!!
@nitin4598
@nitin4598 2 жыл бұрын
Great visualization with pointers !.. My code was giving errors for some edge cases, then watched your video and it helped me. Thank you
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 2 жыл бұрын
Glad you liked it !!
@shakti051
@shakti051 Жыл бұрын
Explained so clear and precise
@aviralkaushik9425
@aviralkaushik9425 2 жыл бұрын
such a great Explanation,, I did not understand the dummy, or what it's working,, but now I totally understand, thank you so much mam🤗
@arjunreddynarala
@arjunreddynarala Жыл бұрын
Great Explanation👌👌, keep doing for more problems.Its a request.
@lavanya_m01
@lavanya_m01 3 жыл бұрын
Awesome explanation!! Thanks :)
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Glad you liked it!!
@aby.t
@aby.t 2 жыл бұрын
great explaination and visual, keep it up!
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 2 жыл бұрын
Glad it was helpful!
@anishsuman1371
@anishsuman1371 4 жыл бұрын
visualization of pointer is very important i like your presentation
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 4 жыл бұрын
Thanks @Anish 🙂
@listentobooks3592
@listentobooks3592 2 жыл бұрын
Great Help 😇thanks
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 2 жыл бұрын
Happy to help
@anujtiwari7218
@anujtiwari7218 2 жыл бұрын
great explanation mam,
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 2 жыл бұрын
Glad you enjoyed it!
@sharuk3545
@sharuk3545 3 жыл бұрын
one of the best Solution
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Thanks!! 😁
@cp65143
@cp65143 Жыл бұрын
Clear and really helpful😇
@sophia0282
@sophia0282 2 жыл бұрын
Thank you sooooo much for the explanation. I had tried to demo the process by myself and got confused.
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 2 жыл бұрын
Glad you liked it !!
@shantanukumar4081
@shantanukumar4081 3 жыл бұрын
great explanation
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Glad it was helpful!
@asifkhan-jk4po
@asifkhan-jk4po 4 жыл бұрын
Explained it nicely.
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 4 жыл бұрын
Thanks @asif !!
@vedantagarwal22
@vedantagarwal22 4 жыл бұрын
Very good explanation . Thankyou !!!
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 4 жыл бұрын
Thanks @Vedant 🤗
@rohandas4172
@rohandas4172 Ай бұрын
Best solution
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy Ай бұрын
Thank you!!!
@bellanatrisha1201
@bellanatrisha1201 Жыл бұрын
thank you so much
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy Жыл бұрын
You're welcome!
@RAJ_K_
@RAJ_K_ 7 ай бұрын
well explained!
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 7 ай бұрын
Thanks
@siddharthdwivedi3263
@siddharthdwivedi3263 3 жыл бұрын
Very nice explaination!!
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Thanks
@prathameshraut6579
@prathameshraut6579 11 ай бұрын
We have used while inside while loop so time complexity will be O(n2) right? Correct me please if I am wrong...
@Apoorvpandey
@Apoorvpandey 2 жыл бұрын
Clean explaination!
@adityasrivastava8196
@adityasrivastava8196 3 жыл бұрын
Awesome Explanation Ma'am !!!!
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Thank you! 🙂
@himanshusharma1066
@himanshusharma1066 3 жыл бұрын
simply amazing solution:-)
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Thanks !!
@binu44464
@binu44464 4 жыл бұрын
nice explanation
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 4 жыл бұрын
Thanks !! 😀
@hydrocy.9165
@hydrocy.9165 7 ай бұрын
2:34 why not prev = head->next?
@noobff5624
@noobff5624 3 ай бұрын
Bcs if we move prev is equal to head ->next then the value 4 will also come that we do not want and this will update the prev That is why we do prev next is equal to head next so we can change prev next any time
@ishaankulkarni49
@ishaankulkarni49 3 жыл бұрын
great video. how do we know when to use a dummy node?
@khushinaudiyal2786
@khushinaudiyal2786 2 жыл бұрын
I wanna know the same thing!
@codersgarage2279
@codersgarage2279 4 жыл бұрын
Well explained. thanks
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 4 жыл бұрын
Thanks @Sudha. Happy coding !!!
@sampannapokhrel
@sampannapokhrel Жыл бұрын
A little confusing. When the head moves from 3 to 4, as said earlier in the video why didn't you move the prev to 4 as well and if you move the prev the algo doesn't work.
@Idk-qg7hb
@Idk-qg7hb Жыл бұрын
awesome video, thanks
@kuldeepparmar6782
@kuldeepparmar6782 Жыл бұрын
mam if you use ListNode dummy = new ListNode(0); does it give same result why we should use ListNode dummy = new ListNode(0, head);
@yereneager
@yereneager Жыл бұрын
if u use first ListNode dummy = new ListNode(0), then in next line you need to also specify dummy.next = head, both are same thing
@korosensei3780
@korosensei3780 3 жыл бұрын
how will duplicate->next return only the required nodes ?
@PankajYadav-kf3dl
@PankajYadav-kf3dl 2 жыл бұрын
Mam at the end, "prev" pointer will also come to node 5, right?
@systemforge
@systemforge 3 жыл бұрын
Brilliant
@pydjango9812
@pydjango9812 3 жыл бұрын
Thanks
@bhupeshbhatt4849
@bhupeshbhatt4849 2 жыл бұрын
Crisp | करारा
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy Жыл бұрын
👌👌
@naveenyadav3700
@naveenyadav3700 3 жыл бұрын
🥰 great
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Thanks !!
@shivendrayadav3991
@shivendrayadav3991 3 жыл бұрын
Time Complexity you explained is Wrong ... In best case it would be O(n) else it will be O(n)^2.
@sahilbarua5202
@sahilbarua5202 2 жыл бұрын
no it will always be o(n) cause the outer loop does not iterates over the skipped element that inner loop does
@sssumeet
@sssumeet 2 жыл бұрын
great
@gantakailashnath
@gantakailashnath Жыл бұрын
Can anyone tell me why this code is getting runtime error in gfg. Node* removeAllDuplicates(struct Node* head) { //code here Node* dummy=new Node(0); dummy->next=head; Node* prev=dummy; Node* temp=head; Node* nextnode=temp->next; while(nextnode!=NULL) { if(temp->data==nextnode->data) { while(temp->data==nextnode->data && nextnode!=NULL) { nextnode=nextnode->next; } prev->next=nextnode; temp=nextnode; nextnode=nextnode->next; } else { prev=temp; temp=nextnode; nextnode=nextnode->next; } } return dummy->next; }
@louischou6780
@louischou6780 3 жыл бұрын
why do we need to do head = head.next in line 27?
@manojpatil7351
@manojpatil7351 3 жыл бұрын
If values are not equal we need to move both prev and head so after moving prev we move head
@SatishKanaujiyaeb
@SatishKanaujiyaeb 3 жыл бұрын
Edge case this solution will fail when when size =1
@adityachowdhury20
@adityachowdhury20 2 жыл бұрын
How it is O(n)?
@cricsinghvlogz
@cricsinghvlogz 4 жыл бұрын
nice
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 4 жыл бұрын
Thanks Pawan 👍👍
@xinniu3145
@xinniu3145 3 жыл бұрын
When I conver this to python, it does not work, could anyone explain that to me? Thank you! class Solution: def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]: dummy = ListNode(0, head) prev = dummy while head: if head.next and head.next.val==head.val: while head.next and head.next.val==head.val: head = head.next prev = head.next else: prev = prev.next head = head.next return dummy.next
@xinniu3145
@xinniu3145 3 жыл бұрын
Hi, could anyone explain why dummy will point to the first non-duplicate node in the code? when you run prev.next = head.next, the dummy.next will also point to head.next, right? why this is the case? And why dummy just stop at the first non-duplicate node and won't go to the end of the list when you run prev = prev.next?
@dillitimalsina6003
@dillitimalsina6003 2 жыл бұрын
actually you are blurred my brother....yes when prev.next points to head.next dummy.next also points to head.next but if head.val!=head.next.val we shifted our pre=prev.next so only the referernce pre is shifted the actual object isn't been modified .so for that reason dummy sticks to the very first.....Thanks
@ranbirpalsingh2245
@ranbirpalsingh2245 2 жыл бұрын
Can anyone explain how actually the dummy pointer is getting changed?
@ranbirpalsingh2245
@ranbirpalsingh2245 2 жыл бұрын
Eg. If we create temp= head pointer whatever changes we make to temp will not get reflected in head pointer then how the dummy pointer is getting modified?
@devinpadron5
@devinpadron5 9 ай бұрын
@@ranbirpalsingh2245 The "dummy" and "prev" share the same node. So when prev->next is changed, it is also changed for the dummy.
@kaustavsaha1117
@kaustavsaha1117 2 жыл бұрын
Does someone copy ur code ? 🤣
@vaishnavworkprofile5478
@vaishnavworkprofile5478 3 жыл бұрын
@rkk1990
@rkk1990 3 жыл бұрын
Isn't this a incorrect explanation? We have to just remove the value which is duplicated. Instead you have removed the value itself which is duplicated. Example : 1 -> 2 -> 3 -> 3 -> 4 -> 4 -> 5 ==> 1 -> 2 -> 3 -> 4 -> 5
@Nk22618
@Nk22618 3 жыл бұрын
The question requires only distinct numbers present in original list. So 3 and 4 are not included in the answer
@plutomessi21
@plutomessi21 Жыл бұрын
can we point prev to null
@vamshibhai5855
@vamshibhai5855 10 ай бұрын
Made it damn Easyy
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 10 ай бұрын
Thanks 👍👍
@sivasanjayraahulm7947
@sivasanjayraahulm7947 3 жыл бұрын
Thanks for the clear explanation.
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 жыл бұрын
Glad you liked it !!
@yashindane2844
@yashindane2844 3 жыл бұрын
Thanks
Remove Duplicates from Sorted List - Leetcode 83 - Python
10:47
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
LeetCode 82. Remove Duplicates from Sorted List II
6:40
Engineering Digest
Рет қаралды 2,7 М.
Partition List | Live Coding with Explanation | Leetcode - 86
6:03
Algorithms Made Easy
Рет қаралды 13 М.
Merge Two Sorted Lists | Live Coding with Explanation | Leetcode #21
4:30
Algorithms Made Easy
Рет қаралды 41 М.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 333 М.
L20. Remove duplicates from sorted DLL
12:53
take U forward
Рет қаралды 49 М.
Leetcode - Remove Duplicates from Sorted List II (Python)
8:00
Timothy H Chang
Рет қаралды 6 М.
Remove duplicates from a sorted Linked List | GeeksforGeeks
11:08
GeeksforGeeks
Рет қаралды 15 М.