Тёмный

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

Algorithms Made Easy
Подписаться 38 тыс.
Просмотров 45 тыс.
0% 0

To support us you can donate
Patreon: / algorithmsmadeeasy
UPI: algorithmsmadeeasy@icici
Paypal: paypal.me/algorithmsmadeeasy
Check out our other popular playlists:
✅✅✅[ Tree Data Structure ] : • Tree Data Structure
✅✅✅[ Graphs Data Structure ] : • Graph Data Structure
✅✅✅[ December Leetcoding Challenge ] : • December Leetcoding Ch...
✅✅✅[ November Leetcoding Challenge ] : • November Leetcoding Ch...
✅✅✅[ August Leetcoding Challenges ] : • August LeetCoding Chal...
✅✅✅[ July Leetcoding Challenges ] : • July LeetCoding Challe...
✅✅✅[ Cracking the Coding Interview - Unique String ] : • Cracking the Coding In...
✅✅✅[ June Leetcoding Challenges ] : • June LeetCoding Challe...
✅✅✅[ May Leetcoding challenges ]: • May LeetCoding Challen...
Problem Link: leetcode.com/p...
Code Link : github.com/Alg...
If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful.
#coding #leetcode #programminglife #programmingisfun #programmer #tech #software #codinglife #leetcode

Опубликовано:

 

9 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 94   
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
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 ] : ru-vid.com/group/PLJtzaiEpVo2zx-rCqLMmcFEpZw1UpGWls ✅✅✅[ Graphs Data Structure ] : ru-vid.com/group/PLJtzaiEpVo2xg89cZzZCHqX03a1Vb6w7C ✅✅✅[ January Leetcoding Challenge 2021 ] : ru-vid.com/group/PLJtzaiEpVo2wCalBcRcNjXQ0C6ku3dRkn ✅✅✅[ December Leetcoding Challenge 2020 ] : ru-vid.com/group/PLJtzaiEpVo2xo8OdPZxrpybGR8FmzZpCA ✅✅✅[ November Leetcoding Challenge 2020 ] : ru-vid.com/group/PLJtzaiEpVo2yMYz5RPH6pfB0wNnwWsK7e ✅✅✅[ August Leetcoding Challenge 2020 ] : ru-vid.com/group/PLJtzaiEpVo2xu4h0gYQzvOMboclK_pZMe ✅✅✅ [ July Leetcoding Challenge 2020] : ru-vid.com/group/PLJtzaiEpVo2wrUwkvexbC-vbUqVIy7qC- ✅✅✅ [ June Leetcoding Challenge 2020 ] : ru-vid.com/group/PLJtzaiEpVo2xIfpptnCvUtKrUcod2zAKG ✅✅✅ [May Leetcoding Challenge 2020 ] : ru-vid.com/group/PLJtzaiEpVo2wRmUCq96zsUwOVD6p66K9e ✅✅✅Cracking the Coding Interview - Unique String: ru-vid.com/group/PLJtzaiEpVo2xXf4LZb3y_BopOnLC1L4mE Struggling in a question?? Leave in a comment and we will make a video!!!🙂🙂🙂
@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.
@poetryiscodingdecoding7965
@poetryiscodingdecoding7965 Год назад
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 Год назад
Glad you enjoyed it!
@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 11 дней назад
Free the memory before the program ends?
@lavanyam3224
@lavanyam3224 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!
@consistentthoughts826
@consistentthoughts826 3 года назад
Very good explanation I was not able to visualise like this Now I am able to solve
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
Thanks @Renuka Glad you liked it !! Keep learning, happy coding !!!
@badabeta6973
@badabeta6973 11 месяцев назад
this is the best explanation I found so far
@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 !!
@RAJ_K_
@RAJ_K_ 2 месяца назад
well explained!
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 2 месяца назад
Thanks
@bellanatrisha1201
@bellanatrisha1201 Год назад
thank you so much
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy Год назад
You're welcome!
@ziyadauti3676
@ziyadauti3676 11 месяцев назад
Best explanation compared to all other videos on this question #82 ....🤗
@shakti051
@shakti051 8 месяцев назад
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🤗
@vedantagarwal22
@vedantagarwal22 3 года назад
Very good explanation . Thankyou !!!
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
Thanks @Vedant 🤗
@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 2 года назад
great explanation
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 2 года назад
Glad it was helpful!
@anishsuman1371
@anishsuman1371 3 года назад
visualization of pointer is very important i like your presentation
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
Thanks @Anish 🙂
@arjunreddynarala
@arjunreddynarala 10 месяцев назад
Great Explanation👌👌, keep doing for more problems.Its a request.
@yashindane2844
@yashindane2844 2 года назад
Thanks
@sharuk3545
@sharuk3545 3 года назад
one of the best Solution
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
Thanks!! 😁
@sivasanjayraahulm7947
@sivasanjayraahulm7947 3 года назад
Thanks for the clear explanation.
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
Glad you liked it !!
@cp65143
@cp65143 8 месяцев назад
Clear and really helpful😇
@listentobooks3592
@listentobooks3592 Год назад
Great Help 😇thanks
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy Год назад
Happy to help
@anujtiwari7218
@anujtiwari7218 Год назад
great explanation mam,
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy Год назад
Glad you enjoyed it!
@systemforge
@systemforge 2 года назад
Brilliant
@prathameshraut6579
@prathameshraut6579 6 месяцев назад
We have used while inside while loop so time complexity will be O(n2) right? Correct me please if I am wrong...
@siddharthdwivedi3263
@siddharthdwivedi3263 3 года назад
Very nice explaination!!
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
Thanks
@binu44464
@binu44464 3 года назад
nice explanation
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
Thanks !! 😀
@Apoorvpandey
@Apoorvpandey 2 года назад
Clean explaination!
@himanshusharma1066
@himanshusharma1066 3 года назад
simply amazing solution:-)
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
Thanks !!
@ishaankulkarni49
@ishaankulkarni49 3 года назад
great video. how do we know when to use a dummy node?
@khushinaudiyal2786
@khushinaudiyal2786 2 года назад
I wanna know the same thing!
@bhupeshbhatt4849
@bhupeshbhatt4849 Год назад
Crisp | करारा
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy Год назад
👌👌
@codersgarage2279
@codersgarage2279 3 года назад
Well explained. thanks
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
Thanks @Sudha. Happy coding !!!
@Idk-qg7hb
@Idk-qg7hb Год назад
awesome video, thanks
@sssumeet
@sssumeet 2 года назад
great
@korosensei3780
@korosensei3780 2 года назад
how will duplicate->next return only the required nodes ?
@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.
@adityasrivastava8196
@adityasrivastava8196 3 года назад
Awesome Explanation Ma'am !!!!
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
Thank you! 🙂
@hydrocy.9165
@hydrocy.9165 2 месяца назад
<a href="#" class="seekto" data-time="154">2:34</a> why not prev = head->next?
@kuldeepparmar6782
@kuldeepparmar6782 8 месяцев назад
mam if you use ListNode dummy = new ListNode(0); does it give same result why we should use ListNode dummy = new ListNode(0, head);
@pain9569
@pain9569 7 месяцев назад
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
@naveenyadav3700
@naveenyadav3700 2 года назад
🥰 great
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 2 года назад
Thanks !!
@PankajYadav-kf3dl
@PankajYadav-kf3dl 2 года назад
Mam at the end, "prev" pointer will also come to node 5, right?
@SatishKanaujiyaeb
@SatishKanaujiyaeb 3 года назад
Edge case this solution will fail when when size =1
@cricsinghvlogz
@cricsinghvlogz 3 года назад
nice
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
Thanks Pawan 👍👍
@gantakailashnath
@gantakailashnath 8 месяцев назад
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; }
@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
@adityachowdhury20
@adityachowdhury20 2 года назад
How it is O(n)?
@xinniu3145
@xinniu3145 2 года назад
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
@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
@xinniu3145
@xinniu3145 2 года назад
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
@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 4 месяца назад
@@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 2 года назад
@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 5 месяцев назад
Made it damn Easyy
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 5 месяцев назад
Thanks 👍👍
@asifkhan-jk4po
@asifkhan-jk4po 3 года назад
Explained it nicely.
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
Thanks @asif !!
@pydjango9812
@pydjango9812 2 года назад
Thanks
Далее
ГИГАЧАД МЭЙКЕР В PLANTS VS ZOMBIES 2!
00:49
Cute
00:16
Просмотров 2,5 млн
LeetCode 82. Remove Duplicates from Sorted List II
6:40
Premature Optimization
12:39
Просмотров 803 тыс.
Remove duplicates from sorted linked list ||
9:11
Просмотров 5 тыс.
The Flaws of Inheritance
10:01
Просмотров 938 тыс.
Learn Java in 14 Minutes (seriously)
14:00
Просмотров 4,7 млн
ГИГАЧАД МЭЙКЕР В PLANTS VS ZOMBIES 2!
00:49