bro tum bahut badia dsa padate ho better then all youtubers.
@aishwarya80782 жыл бұрын
Bhaiya kya samjhaya hai aapne... literally hats off 🙌 slow and fast pointer ka concept.....ekdum clear ho gaya
@HelloWorldbyprince2 жыл бұрын
thanks a lot dear Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
@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 Жыл бұрын
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
i have solved almost correct except the edge case must watch explanation ❤❤
@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 Жыл бұрын
Really bhaiya aapne bahut easy way se samjhaya. Thank you
@HelloWorldbyprince Жыл бұрын
keep learning like this and keep sharing my channel
@aadityasinghrana8245 Жыл бұрын
thanks for the video bhaiya ji.... u r great !! please keep on going .... love u bhaiya aka guru ji ! 🙏🙏🙏
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 😊.
@HelloWorldbyprince2 жыл бұрын
waooo
@djpsn7094 Жыл бұрын
Great explained 🙌
@HelloWorldbyprince Жыл бұрын
Glad you liked it
@Vegeta-ew2bq Жыл бұрын
Great vid!😀
@HelloWorldbyprince Жыл бұрын
Thanks a lot
@saini.mayank2 жыл бұрын
thanks bhai, but DP series
@HelloWorldbyprince2 жыл бұрын
welcome bro soon upload
@Student-q7n3 ай бұрын
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 ; }
@dharmeshgohil93752 жыл бұрын
awesome
@HelloWorldbyprince2 жыл бұрын
Thanks
@dummy7330 Жыл бұрын
int count=0; while(temp!=NULL){ count++; temp=temp->next; } int m=count-n+1; if(count==NULL){ return 0; }
@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 Жыл бұрын
Sir could you please make a video on null pointer error thrown by leetcode 😭
@yashpaunikar6719 ай бұрын
13:47 slow ka next ya head ka next kyo return kiya sir...? if return slow ya head krenge to kya hoga
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 Жыл бұрын
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_smarter2 жыл бұрын
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_smarter2 жыл бұрын
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
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; }
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 Жыл бұрын
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 Жыл бұрын
Bhaiya explaination dekhne k baad code dekhne ki jarurat nhi padi.
@adityarout12762 жыл бұрын
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;
@HelloWorldbyprince2 жыл бұрын
nice bro keep it up
@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 Жыл бұрын
Use siz in while loop instead of count
@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.