Remove Nth Node From End of List ❤️ | Leetcode DSA Linked List Solution Playlist Hindi Hello World

  Рет қаралды 16,553

Hello World

Hello World

Күн бұрын

Пікірлер: 91
@ankitgaur7428
@ankitgaur7428 7 ай бұрын
bro tum bahut badia dsa padate ho better then all youtubers.
@aishwarya8078
@aishwarya8078 2 жыл бұрын
Bhaiya kya samjhaya hai aapne... literally hats off 🙌 slow and fast pointer ka concept.....ekdum clear ho gaya
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
thanks a lot dear Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
@abhijeetsingh8310
@abhijeetsingh8310 Жыл бұрын
Love and respect from Ramgarh 🚩end to end following your instructions my friend from Delhi suggested your playlist Bagal mein chhoda Shahar mein dindora wala haal h
@amitkumarthakur6937
@amitkumarthakur6937 Жыл бұрын
after watching this vides, it help me a lot and in middle i tried myself and in first attempt i solev it and finally it accepted thanks a lots ur motivation to solve by urself work on me
@techykushwaha6848
@techykushwaha6848 Жыл бұрын
Bhaiya Bahut bahut bahut badiya samjhaya aapne, mukembo khush hua🙌🔥
@uditpanjiyar3203
@uditpanjiyar3203 Жыл бұрын
i have solved almost correct except the edge case must watch explanation ❤❤
@actionworld7009
@actionworld7009 Жыл бұрын
The main problem of most of the student is, they can solve problem, and can build logic also but they can't tell that logic to computer, even they know c++ and other language if they know how to talk with computer, then problem become easy to solve.
@sourabhpal9422
@sourabhpal9422 Жыл бұрын
Really bhaiya aapne bahut easy way se samjhaya. Thank you
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
keep learning like this and keep sharing my channel
@aadityasinghrana8245
@aadityasinghrana8245 Жыл бұрын
thanks for the video bhaiya ji.... u r great !! please keep on going .... love u bhaiya aka guru ji ! 🙏🙏🙏
@MohitArya-j3n
@MohitArya-j3n Жыл бұрын
bhaiya aagya samj me
@ravilpatel7301
@ravilpatel7301 2 жыл бұрын
ListNode *temp = head; int count = 0; while(temp!=NULL){ temp=temp->next; count++; } temp = head; for(int i=1;inext; } if(count-n==0){ return head->next; } if(temp->next!=NULL){ temp->next = temp->next->next; return head; }else{ return NULL; }
@creative505
@creative505 Жыл бұрын
Really it's logic very helpful.
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Keep watching
@sushmajha3432
@sushmajha3432 Жыл бұрын
thank u bhaiya
@shraddhapotekar7482
@shraddhapotekar7482 9 ай бұрын
Tysm😊
@salmaniproductions1104
@salmaniproductions1104 8 ай бұрын
2nd approach bhaiyaa: ListNode* temp = head; int size=0; while(temp->next!=NULL){ temp=temp->next; size++; } if(size==n){ return head->next; }
@incubus8492
@incubus8492 Жыл бұрын
maza agaya bhaiya
@Manikaushaki
@Manikaushaki Жыл бұрын
ListNode* fast, *slow; fast = slow = head; for(int i=0; inext; ListNode* temp = head; if(!fast){ head = head->next; delete temp; return head; } while(fast->next){ fast = fast->next; slow = slow->next; } temp = slow->next; slow->next = temp->next; delete temp; return head;
@sidranaeem7334
@sidranaeem7334 2 жыл бұрын
mere ko samjh aa gya
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
nice bro
@impulsivedamon
@impulsivedamon Жыл бұрын
smj gya
@googlebaba4045
@googlebaba4045 2 жыл бұрын
dhanewad bhaiya
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
keep learning yaar Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
@theengineerguy_
@theengineerguy_ 2 жыл бұрын
Thank you Prince bhai🎉
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
thanks kaish bro
@amritpandey815
@amritpandey815 Жыл бұрын
class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode* temp =head; int count=0; if(temp == NULL)return head; while(temp!=NULL) { temp=temp->next; count++; } temp=head; int deleteEle=count-n-1; if(count==n) { return head->next; } while(deleteEle!=0 && temp!=NULL) { temp=temp->next; deleteEle--; } if(temp!=NULL) { temp->next=temp->next->next; } else { return NULL; } return head; } }; Thanks for uploading wonderful series of linked list
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
amazing works good 👏
@amritpandey815
@amritpandey815 Жыл бұрын
@@HelloWorldbyprince Thank you bhaiya
@prakritiagrawal198
@prakritiagrawal198 9 ай бұрын
Good explaination👍
@HelloWorldbyprince
@HelloWorldbyprince 7 ай бұрын
Thank you 😃
@neelpunia2541
@neelpunia2541 2 жыл бұрын
great playlist, prince bhai , eagerly waiting for dp playlist ❤❤
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Very soon
@siddheshsurve6608
@siddheshsurve6608 Жыл бұрын
Best video
@faizaniit
@faizaniit Жыл бұрын
awesome question brother
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
keep doing hard working
@baladimirputin708
@baladimirputin708 Жыл бұрын
I am Also Prince Kumar
@mddanish2016
@mddanish2016 2 жыл бұрын
Thanks bhaiya 😍
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Keep learning bro
@salmaniproductions1104
@salmaniproductions1104 8 ай бұрын
thnk you so much sir
@HelloWorldbyprince
@HelloWorldbyprince 7 ай бұрын
Most welcome
@prakashnandan7337
@prakashnandan7337 Жыл бұрын
Thank you so much Bhaiya
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Always welcome
@AdityaSingh-wg3tv
@AdityaSingh-wg3tv 2 жыл бұрын
ListNode* removeNthFromEnd(ListNode* head, int n) { int c=0; ListNode* cur=head; if(cur->next==NULL) return NULL; while(cur){ c++; cur=cur->next; } if(c==n){ head=head->next; } else{ ListNode*prev=head; for(int i=0;inext; } prev->next=prev->next->next; } return head; }
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
nice work
@abhaytomar6288
@abhaytomar6288 2 жыл бұрын
class Solution { private: int countListNodes(ListNode*n) { int cnt=0; while(n!=NULL) { n=n->next; cnt++; } return cnt; } public: ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode* current = head; int cnt =countListNodes(head); if(cnt == n) { return head->next; } int desiredNode = cnt-n-1; while(desiredNode--) { current = current->next; } ListNode* temp = current->next; current->next = current->next->next; delete temp; return head; } }; Bhaiya i really want to thank you for that i had watched 4-5 playlist of linked list before but even though could not much understand the fundaments of it. But by watching your videos the way you explained it really cleared all my gaps in the fundamentals of Linked List . And Now i am find myself in a position where i am quite comfortable in solving questions 😊.
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
waooo
@djpsn7094
@djpsn7094 Жыл бұрын
Great explained 🙌
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Glad you liked it
@Vegeta-ew2bq
@Vegeta-ew2bq Жыл бұрын
Great vid!😀
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
Thanks a lot
@saini.mayank
@saini.mayank 2 жыл бұрын
thanks bhai, but DP series
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
welcome bro soon upload
@Student-q7n
@Student-q7n 3 ай бұрын
approach 1 ListNode* removeNthFromEnd(ListNode* head, int n) { if(head==NULL || nnext; count++ ; } curr=head ; ListNode* prev=NULL ; int x=count-n; if(x==0){ curr=head; head=curr->next; return head ; } while(x--){ prev=curr; curr=curr ->next; } if(curr==NULL) return head ; prev->next=curr->next; delete(curr); return head ; }
@dharmeshgohil9375
@dharmeshgohil9375 2 жыл бұрын
awesome
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Thanks
@dummy7330
@dummy7330 Жыл бұрын
int count=0; while(temp!=NULL){ count++; temp=temp->next; } int m=count-n+1; if(count==NULL){ return 0; }
@mahimatolani813
@mahimatolani813 Жыл бұрын
I have one question that in this other way also we are just first pointing fast node till n place and then with 1 traversal we are doing in naïve approach as well first we calculate size and then in traversal we delete the node from end anyhow both ways are using 2 traversals. Please correct me if I am wrong.
@namanmishra5683
@namanmishra5683 Жыл бұрын
Sir could you please make a video on null pointer error thrown by leetcode 😭
@yashpaunikar671
@yashpaunikar671 9 ай бұрын
13:47 slow ka next ya head ka next kyo return kiya sir...? if return slow ya head krenge to kya hoga
@Gangehum
@Gangehum 2 жыл бұрын
sir please make video on array
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
sure brother
@bhuvandahal421
@bhuvandahal421 Жыл бұрын
class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { if(!head->next) return nullptr; int sz = 2; ListNode* ptr = head->next->next; while(ptr) { ++sz; ptr = ptr->next; } int t = sz - n; ptr = head; if(t == 0) { head = head->next; delete ptr; return head; } while(t != 1) { --t; ptr = ptr->next; } ListNode* temp = ptr->next; ptr->next = temp->next; delete temp; return head; } };
@prakashnandan7337
@prakashnandan7337 Жыл бұрын
Apporach 1 if(head == NULL){ return head; } ListNode* temp = head; int k=0; while(temp != NULL){ k++; temp=temp->next; } if(n == k){ return head->next; } int count =1; ListNode* curr = head; while(count < k-n && curr != NULL){ curr=curr->next; count++; } if(curr->next != NULL){ curr->next=curr->next->next; } else{ return NULL; } return head;
@ShreyaSingh-gm1pk
@ShreyaSingh-gm1pk Жыл бұрын
class Solution { public ListNode removeNthFromEnd(ListNode head, int n) { int count=0; ListNode curr=head; if(curr.next==null) return null; while(curr!=null){ count++; curr=curr.next; } if(count==n){ head=head.next; } else{ ListNode prev=head; for(int i=0;i
@amanbhaisare5058
@amanbhaisare5058 Жыл бұрын
C++ Solution ListNode* removeNthFromEnd(ListNode* head, int n) { if(head == NULL && head -> next == NULL) return head; ListNode* curr = head; int len=0; while(curr!=NULL){ curr = curr -> next; len++; } curr = head; int m = len - n ; cout
@Everyday_smarter
@Everyday_smarter 2 жыл бұрын
class Solution { public: int i=0; int m=0; ListNode* found; void dis(ListNode* head) { if(head==NULL) { return; } dis(head->next); i++; if(i==m) { found=head; //return; } // cout
@Everyday_smarter
@Everyday_smarter 2 жыл бұрын
so in if we have n==1 then in wrost case we have to go it's previous node and then delete it otherwise in all other cases we don't have to do that
@niteshk0487
@niteshk0487 2 жыл бұрын
My own approac #someting else✔ class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { if(head == NULL && head->next == NULL) return NULL; int count = 0; ListNode *temp = head; while(temp != NULL) { count++; temp = temp->next; } if(count == n) return head->next; temp = head; count = count-1; while(count > n) { temp =temp->next; count--; } temp->next = temp->next->next; return head; } };
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
Amazing Nitesh keep growing
@akashkumarverma1969
@akashkumarverma1969 2 жыл бұрын
Bhaiya Mai 1st Approch Try Kr rha but jab main ye line ptrr->next=ptrr->next->next; likh rha Jisko delte krna ha uske phle aur uske baad wale ko connect krne ke liye Phir Usi Pos pe Runtime Error De rha Baki maine sara Code May be sahi LIKha ha ListNode* removeNthFromEnd(ListNode* head, int n) { if(head==NULL)return head; ListNode* ptr=head; int c=0; while(ptr!=NULL) { ptr=ptr->next; c++; } if(n==c) { ListNode*t=head->next; delete head; return t; } int s=c-n+1; int i=0; ListNode* ptrr=head; while(inext; i++; } ListNode* temp=ptrr->next; delete temp; ptrr->next=ptrr->next->next; return head; }
@prakashnandan7337
@prakashnandan7337 Жыл бұрын
check for prev->next is NOT NULL if(head == NULL){ return head; } ListNode* temp = head; int k=0; while(temp != NULL){ k++; temp=temp->next; } if(n == k){ return head->next; } int count =1; ListNode* curr = head; while(count < k-n && curr != NULL){ curr=curr->next; count++; } if(curr->next != NULL){ curr->next=curr->next->next; } else{ return NULL; } return head;
@masumali8356
@masumali8356 Жыл бұрын
if(head == NULL){ return head; } ListNode* temp = head; int k=0; while(temp != NULL){ k++; temp=temp->next; } if(n == k){ return head->next; } int count =1; ListNode* curr = head; while(count < k-n && curr != NULL){ curr=curr->next; count++; } if(curr->next != NULL){ curr->next=curr->next->next; } else{ return NULL; } return head;
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
nice work
@amitkumarthakur6937
@amitkumarthakur6937 Жыл бұрын
ListNode* temp=head; ListNode* temp2=head; if(head->next==nullptr) return nullptr; int count =0; while(temp){ count++; temp=temp->next; } if(count==n) return head->next; int x=count-n; for(int i=1; inext=temp2->next->next; } else{ temp2=temp2->next; } } return head;
@krushnapatil9196
@krushnapatil9196 Жыл бұрын
W
@amanbhaisare5058
@amanbhaisare5058 Жыл бұрын
Khudse attempt kiya tha bhaiya
@HelloWorldbyprince
@HelloWorldbyprince Жыл бұрын
nice
@astkh4381
@astkh4381 2 жыл бұрын
thank you for video. Could you please help me understand when does the element in dummy gets updated? All I see is fast and slow move forward but it is not clear to me how assigning slow.next=slow.next.next affects the actual dummy list
@shivendrasingh2527
@shivendrasingh2527 Жыл бұрын
bhaiya what is the issue with my approach. it is showing error. class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode *curr=head;int count=0; if(curr==NULL) { return head; } while(curr!=NULL) { count++; curr=curr->next; } if(count==n) { head=head->next; } curr=head; count=0; while(curr) { if(count==n) { curr->next=curr->next->next; } curr=curr->next; count++; } return head; } };
@VivekPathak-ds2do
@VivekPathak-ds2do Жыл бұрын
Bhaiya explaination dekhne k baad code dekhne ki jarurat nhi padi.
@adityarout1276
@adityarout1276 2 жыл бұрын
First Approach Code : ListNode *dummyNode=new ListNode; dummyNode->next=head; ListNode *temp=head; int size=1; while(temp->next!=NULL){ temp=temp->next; size++; } int pos=size-n+1; int cnt=1; if(size==n){ return head->next; } ListNode *prev=dummyNode; ListNode *curr=head; ListNode *next=head->next; while(cnt!=pos){ next=next->next; curr=curr->next; prev=prev->next; ++cnt; } prev->next=next; curr->next=NULL; return dummyNode->next;
@HelloWorldbyprince
@HelloWorldbyprince 2 жыл бұрын
nice bro keep it up
@leisuretime4198
@leisuretime4198 Жыл бұрын
bhaiya please bta dijiye kk isme runtime error kyu aa rha hai ?? class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode* count_ptr=head; ListNode* temp=head; int count=0; while(count_ptr){ count_ptr=count_ptr->next; count++; } if(count==n)return head->next; int siz=count-n-1; while(count--){ temp=temp->next;} temp->next=temp->next->next; return head; } };
@harshitgoel4257
@harshitgoel4257 Жыл бұрын
Use siz in while loop instead of count
@leisuretime4198
@leisuretime4198 Жыл бұрын
class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode* temp=head; int count=1; while(temp!=NULL){ temp=temp->next; count++; } int nn=count-n;//from beginning if(nn==1) return head->next; ListNode* t=head; nn=nn-1;//3 while(nn>1){ t=t->next; nn--; } t->next=t->next->next; return head; } }; Completed in the first attempt this time.
@leisuretime4198
@leisuretime4198 Жыл бұрын
@@harshitgoel4257
@keluthsanjeevkumar3074
@keluthsanjeevkumar3074 Жыл бұрын
thanks bhayya
CSMT Platforms Tour: Local and Express
9:02
WAK Vlogs (Wajid Ali Khan)
Рет қаралды 68
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 25 МЛН
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 6 МЛН
How I Mastered Data Structures and Algorithms in 8 Weeks
15:46
Aman Manazir
Рет қаралды 103 М.
Remove nth node from end of Linked List | Leetcode
17:50
Coding Wallah Sir
Рет қаралды 1,6 М.
L22. Rotate a LinkedList
12:10
take U forward
Рет қаралды 72 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 696 М.
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 25 МЛН