bhaiya ...agar hum ans wale function m insertAtHead krde toh last mai ans wali list ko reverse nhi karna padhega ,,,which will save time.....please check and reply
@mehulsaraswat26882 жыл бұрын
Course achi trh se follow kr rha hu. Party zaroor dunga placement k baad. Thankuu bhaiya 👍
@divashgupta58712 жыл бұрын
Mujhe bhi de dena bro😅😁
@nikhilrana98252 жыл бұрын
muje bhi bro
@ankitmusic132 жыл бұрын
hua bhai placement?????
@Akash-yr2if Жыл бұрын
Hua Placement
@akshaykumar192 Жыл бұрын
Ho gya placement ?
@manishrawat37912 жыл бұрын
Bhaiya consistency ++ .... bhaiya vase ek baat volu toh ajj kal quality ek number mil rhi hai phele bh milti th vase . Aur sach btau toh khud se man kr rha hai ki kuch kru.. and you will not believe me I have solved more than 180+ question in last 2 months . and before 2 month I am not even able to understand the concept of question . So big thanks bhaiya I really love your videos
@anshraj21962 жыл бұрын
Plz suggest me , I am in second semester currently am learning c++ . So Can I start DSA course side by side with c++ or first i should complete c++
@cs_in_10_minutes10 ай бұрын
bhai, kahan pe job lagi aapki?
@9852963775aaa2 жыл бұрын
in love with this series >>>>>>>>
@mohdtalib9342 жыл бұрын
we can use insertAtHead then we don't need to reverse the ans LL; nice video bhaiya
@shubhampatel_2745 Жыл бұрын
wow amazing point really appreciation you.
@lakshsinghania Жыл бұрын
bro, this code doesnt work on leetcode idk why i tried a lot still
@ayushbudhlakoti200410 ай бұрын
bhaiya ...agar hum ans wale function m insertAtHead krde toh last mai ans wali list ko reverse nhi karna padhega ,,,which will save time.....please check and reply
@priyanshukumarsah27464 ай бұрын
nice observation bro ! good keep it up 😇
@karanborana85402 жыл бұрын
Hats off to your consistency and quality of the videos! ❤️💯 Totally loving it!
@ayushbudhlakoti200410 ай бұрын
bhaiya ...agar hum ans wale function m insertAtHead krde toh last mai ans wali list ko reverse nhi karna padhega ,,,which will save time.....please check and reply
@divyagupta6854 Жыл бұрын
I was little bit confused at a different approach I saw where reversal was not done. But doing reversal really makes this problem simple enough to understand and solve. Thanks for this approach.
@ayushbudhlakoti200410 ай бұрын
bhaiya ...agar hum ans wale function m insertAtHead krde toh last mai ans wali list ko reverse nhi karna padhega ,,,which will save time.....please check and reply
@vanshgambhir78059 ай бұрын
Anyone who is trying to solve this question now getting stuck it is because test cases have changed i guess so add these lines before returning your ans pointer in your addtwolists function while((ans->data)==0&&ans->next!=NULL){ Node* temp=ans; delete(temp); ans=ans->next; }
@@thebhrotherslakshya2005 you can try running the code without it by only writing bhaiya's approach and you will eventually if you try the test cases and carefully observe u will get 0 is not needed at start which is logically correct if we are adding two numbers but using the approach shown in video we are reversing and there is a chance we will get zero at the starting so i wrote an additional line so that all zero's at starting gets deleted and it's important to check if it doesn't reach the null pointer that's it observation is the key while solving and debugging do dry runs
@thebhrotherslakshya20056 ай бұрын
Thanks bhai.. for explanation
@jagratgupta83922 жыл бұрын
bhaiya generic code part was the best ...........best course for linked list ....thanks bhaiya
@AgamRaj-p5q4 ай бұрын
Now I complete lecture 51 still energetic like 1st one becoz of your ultimate energy and teaching skills
@ujwalbarodia43132 жыл бұрын
Bhaiya done pura up to date hogya bht back log tha Ab ek dum tym pe naya video dekhege Bhiaya meko lagta hai views kam hue uska reason logon ka backlog hai to aap continue krte raho ye KZbin ka best course hai and maybe best free course available.... Thank you bhaiya Attendance++;
@ayushbudhlakoti200410 ай бұрын
bhaiya ...agar hum ans wale function m insertAtHead krde toh last mai ans wali list ko reverse nhi karna padhega ,,,which will save time.....please check and reply
@RohitRana-tz2lr2 жыл бұрын
Bhaiya consistency++... Thank you so much bhaiya for all of your hardwork and dedication ... lucky to get a mentor like you
@ayushbudhlakoti200410 ай бұрын
bhaiya ...agar hum ans wale function m insertAtHead krde toh last mai ans wali list ko reverse nhi karna padhega ,,,which will save time.....please check and reply
@itskaaryan7 Жыл бұрын
thank u love babbar bhaiya for such precious lectures.
@vipulagarwal29962 жыл бұрын
thanku so much babbar bhaiya for the amazing lectures👍👍
@subhambasuroychowdhury96982 жыл бұрын
Awesome video, was able to write the code just after listening to the Problem Statement with the NULL checks and edge cases. Thank you very much
@ujjwalverma_2 жыл бұрын
Maja aa gya Bhaiya waiting for next video
@rawat_ji51832 жыл бұрын
perfect explanation bhiya ❤
@shazeflon14482 жыл бұрын
Hi bro currently you are on which lecture?
@rawat_ji51832 жыл бұрын
@@shazeflon1448 topic :- Binary trees 67
@shazeflon14482 жыл бұрын
Great yaar , I'll start stacks ...bro can i discuss with you the approach of some questions I'm kinda getting stuck at if you don't mind
@rawat_ji51832 жыл бұрын
@@shazeflon1448 sure
@shazeflon14482 жыл бұрын
Okay great
@sushovanchakraborty49082 ай бұрын
Sab samaj AA gaya best explanation sir
@abhirajbais50932 жыл бұрын
bhot mast style hai seekhane ka aapka..SAmay ko samay do ..sb samjh aane lgega..Mazzaa aa rha hai series mai bhot
This can be done in O(1) Space Complexity. Please Bhaiya Give us the most optimized approach till the end. This is the solution for LeetCode question. To use this logic for gfg question we just need to pass heads of lists into reverse function and then perform all operations below. class Solution { public: ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { ListNode* temp1=l1; ListNode* temp2=l2; ListNode* newHead=new ListNode(0); ListNode* ans=newHead; int carry=0; while(temp1!=NULL and temp2!=NULL){ int total=temp1->val+temp2->val+carry; temp1->val=total%10; carry=total/10; ans->next=temp1; ans=ans->next; temp1=temp1->next; temp2=temp2->next; } while(temp1!=NULL){ int total=temp1->val+carry; temp1->val=total%10; carry=total/10; ans->next=temp1; ans=ans->next; temp1=temp1->next; } while(temp2!=NULL){ int total=temp2->val+carry; temp2->val = total%10; carry=total/10; ans->next=temp2; ans=ans->next; temp2=temp2->next; } if(carry!=0){ ans->next=new ListNode(carry); } return newHead->next; } };
@kundanmali2405 Жыл бұрын
Thank you for such grt content bhaiya
@ankurharshit26298 ай бұрын
instead of doing insert at tail, we can do insert at head, then no need to reverse the list
@anshumansharma10692 жыл бұрын
maza aagaya sirr✌✌
@ITA__EshanTiwari10 ай бұрын
Sir ghoom diya is que ne 😵
@vinayakk274510 ай бұрын
better approach: pehle dono linked lists ko numbers mein convert karo, then un numbers ko add karke jo result aayega, use new linked list bana lo, eeeaaazy
@inter39889 ай бұрын
@@vinayakk2745 yeah....easy approach. what if the linked list is of 500 length? where will you store the sum? in long long int? I doubt so..
@abhyaskanaujia38622 жыл бұрын
Thank you for all your efforts. You're the best.
@ayushbudhlakoti200410 ай бұрын
bhaiya ...agar hum ans wale function m insertAtHead krde toh last mai ans wali list ko reverse nhi karna padhega ,,,which will save time.....please check and reply
@108_adityakumar62 жыл бұрын
Your linked list series is best.Thanks bhaiya 🔥🔥
@ahmadrasheed25982 ай бұрын
use this to remove leading zeros in answer list: while (ans != NULL && ans->data == 0) { Node* temp = ans; ans = ans->next; delete temp; // Free the memory of the leading zero node }
@anuptewary30162 жыл бұрын
Present bhaiya with lot's of fire and love 🔥
@ayushbudhlakoti200410 ай бұрын
bhaiya ...agar hum ans wale function m insertAtHead krde toh last mai ans wali list ko reverse nhi karna padhega ,,,which will save time.....please check and reply
@suyashvikramsingh89132 жыл бұрын
bhaiya much2 better than paid courses ,thank u bhaiya
@Nikhil-ke9bq2 жыл бұрын
You are the best bhaiya, placement lagne k baad linkedin pe mention krunga🤩🤩👍
@AA-wy9vw2 жыл бұрын
Loving the series!!
@ayushbudhlakoti200410 ай бұрын
bhaiya ...agar hum ans wale function m insertAtHead krde toh last mai ans wali list ko reverse nhi karna padhega ,,,which will save time.....please check and reply
@udaypratapsingh89232 жыл бұрын
bhaiya doubly linked list ke bhi karva dijiye 🔥🔥🔥🔥🔥.. course op 🔥🔥🔥🔥
@ravishekhawat5958 Жыл бұрын
2nd approach .. Dono link list ke number 2 var me store kr lo .. dono ko sum kro .. And sum se ek ek number extract krke new link list me daal do 🙂
@kumarpawansahh2 жыл бұрын
Bhaiya aapka jitna shukriya da karu utna kamm hai
@prashantbirajdar92712 жыл бұрын
wahh bhaiyaa maza aa gya sub smj aa gyaa❤❤👍👍
@avibirla98632 жыл бұрын
Bhaiya ka new dialogue : RYTHM BREAK NA HO TOH APNE SPONSORS KO SHOUTOUT DE DETE H 😂😎
@CodeHelp2 жыл бұрын
😂
@Shivam-wl7fg Жыл бұрын
Node* getReverse(Node* head){ Node* prev = NULL; Node* curr = head; Node* next = NULL; while(curr != NULL){ next = curr->next; curr->next = prev; prev = curr; curr = next; } return prev; } Node* addTwoLists2(Node* first, Node* second){ // step 1: reverse giveen linked lists Node* head1 = getReverse(first); Node* head2 = getReverse(second); int x; int y; int carry = 0; int n; Node* ans = NULL; Node* temp = NULL; while(head1 != NULL & head2 != NULL){ x = head1->data; y = head2->data; n = x+y+carry; // update ans list int val = n%10; temp = new Node(val); temp->next = ans; ans = temp; head1 = head1->next; head2 = head2->next; carry = n/10; } while(head1 != NULL){ x = head1->data; n = x+carry; // update ans list int val = n%10; temp = new Node(val); temp->next = ans; ans = temp; head1 = head1->next; carry = n/10; } while(head2 != NULL){ x = head2->data; n = x+carry; // update ans list int val = n%10; temp = new Node(val); temp->next = ans; ans = temp; head2 = head2->next; carry = n/10; } if(carry != 0){ int val = carry; temp = new Node(val); temp->next = ans; ans = temp; } return ans; } this approach is update version of love bhaiya
@ABHISHEKKUMAR-bx9px Жыл бұрын
we could have used insertAtHead directly which reduce the need of reversing the ans list at the end
@daanyalparbulkar2573 Жыл бұрын
have you tried it and did it work ❓
@manavsharma142Ай бұрын
Great explanation as always
@palaksolanki80372 жыл бұрын
Loving the series bhaiya😀😀
@muskanagarwal85732 жыл бұрын
u r the best teacher.. bhaiya😊
@funwithrayhan9579 Жыл бұрын
masterclass bhai.. love from bangladesh
@abhijeetbiswas3017 Жыл бұрын
code for 1st approach: class Solution { private: Node* reverse(Node* head) { Node *prev = NULL; Node *curr = head; Node *forward = NULL; while(curr != NULL) { forward = curr -> next; curr -> next = prev; prev = curr; curr = forward; } return prev; } void insertAtTail(struct Node* &head, struct Node* &tail, int value) { Node *temp = new Node(value); if(head == NULL) { head = temp; tail = temp; return; } else { tail -> next = temp; tail = temp; } } struct Node* add(struct Node* first, struct Node* second) { int carry = 0; Node *ansHead = NULL; Node *ansTail = NULL; while(first != NULL && second != NULL) { int sum = carry + first -> data + second -> data; int digit = sum % 10; //create node and add in LL insertAtTail(ansHead, ansTail, digit); carry = sum / 10; first = first -> next; second = second -> next; } while(first != NULL) { int sum = carry + first -> data; int digit = sum % 10; //create node and add in LL insertAtTail(ansHead, ansTail, digit); carry = sum / 10; first = first -> next; } while(second != NULL) { int sum = carry + second -> data; int digit = sum % 10; //create node and add in LL insertAtTail(ansHead, ansTail, digit); carry = sum / 10; second = second -> next; } while(carry != 0) { int sum = carry; int digit = sum % 10; //create node and add in LL insertAtTail(ansHead, ansTail, digit); carry = sum / 10; } return ansHead; } public: //Function to add two numbers represented by linked list. struct Node* addTwoLists(struct Node* first, struct Node* second) { // code here\ //step 1 -> REVERSE THE LLS first = reverse(first); second = reverse(second); //step 2 -> add the LLS Node *ans = add(first, second); //step 3 -> REVERSE THE ANS LL ans = reverse(ans); return ans; } };
@anuptewary30162 жыл бұрын
Maja a gye bhaiya video dekh kar waiting for next video ❤️
@prikshit_sharma40712 жыл бұрын
apka naam roshan kruga guruji ❤️
@aditya_as2 Жыл бұрын
this course>>>>>>>>>>>>
@debajyatibanerjee54802 жыл бұрын
Bhaiya bura mat maniyega ... apka video dekhte dekhte like karna bhul jata hu... sry for that... but dil se thankuuuu... love u babbar bhaiya....
@shivanshisharma37182 жыл бұрын
Bhaiya your content is awwsmm 👍👍 DBMS start kra. Do
@utkarshdubey16182 жыл бұрын
mast padhate ho bhaiya aap . Dil se sukriya aapka ❤
@ayushbudhlakoti200410 ай бұрын
bhaiya ...agar hum ans wale function m insertAtHead krde toh last mai ans wali list ko reverse nhi karna padhega ,,,which will save time.....please check and reply
@mrfactvenger65702 жыл бұрын
Bhai stack and queue ke lectures kab aayege,?
@suvigyabasnotra73782 жыл бұрын
Aapke GFG ka timer kyon nahi visible hai?
@jePastapuramNagashwini Жыл бұрын
class Solution { public: //Function to add two numbers represented by linked list. long long int number(Node* head){ Node* temp=head; long long int num=0; while(temp->next!=NULL){ num=(num+temp->data)*10; temp=temp->next; } num=num+temp->data; return num; } struct Node* addTwoLists(struct Node* &first, struct Node* &second) { long long int num=number(first)+number(second); Node* temp=first; while(temp->next!=NULL){ Node* de=temp->next; temp->next=temp->next->next; delete de; } if(num==0){ Node* n=new Node(0); temp=n; temp->next=NULL; return temp; } int i=0; while(num!=0){ Node* newhead=new Node(num%10); num=num/10; if(i==0){ temp=newhead; } else{ newhead->next=temp; temp=newhead; } i++; } return temp; } }; my code is pretty clumsy confusing and difficult but can anyone tell me where I did do wrong. it's not working for long integers
@vmstudy9965 Жыл бұрын
Mjaa to aa rha h bhiya...🎉🥳
@priyanshujain8622 жыл бұрын
😊😊 thank you bhaiya please continue The important questions of linked list
An easy method: Traverse linked list1 and find the num1 Traverse linked list 2 and find the num2 Add num1 and num2 = sum Now make a new linked list as an answer! Now take the digits of the sum one by one and put it in the answer waala linked list by inserting every digit at the head.
@imPriyansh77 Жыл бұрын
yes, tysm
@vishnubishnoi46214 ай бұрын
error dega for very large input test cases, just wasted a whole day to make that approach work , though logic is correct.
@suyashjain3223 Жыл бұрын
Amazing Video Bhaiyaa 🤩
@anuradha3868 Жыл бұрын
Awesome lecture....thanku so much ❤️🙌
@rudrapratapsinghtomar39252 жыл бұрын
Thankyou soo much for providing such a quality content.
@Akash-yr2if Жыл бұрын
I got diagnosed with CANCER after watching this solution. Either I'll leave this question or get other approch. Ye tow merasa yaad nehi rahega
@devanshusahoo2 жыл бұрын
Thank You bhaiya for the wonderful videos! You have truly helped me develop a love not just for coding but for learning and exploring as well!
@ayushbudhlakoti200410 ай бұрын
bhaiya ...agar hum ans wale function m insertAtHead krde toh last mai ans wali list ko reverse nhi karna padhega ,,,which will save time.....please check and reply
@_A__Mohit2 жыл бұрын
OP lecture and teacher also 💥💥💥💥💥💥💥💥💥💥
@computerguy3550 Жыл бұрын
lAJAVAH aJJ toH maZA hI AHHGYA👌👌👌👌
@ashutoshgiri29742 жыл бұрын
A person name love sharing love at free of cost ❤️ getting so much love from a person falling in love by loving the content of the course
@hasanrants7 ай бұрын
bhaiya sab smjh aagaya, thank you!
@harshkumar76862 жыл бұрын
Last mein optimisation mein maja aa gaya bhaiya . Thank you for your immense support ❤
@Bhagwati_Jewellers.2 жыл бұрын
Amazing bhaiya 😍
@manavsingh5919 Жыл бұрын
Thank Sir Understood everything 😊
@rachit_joshi10 ай бұрын
Thank You So Much BHRATA SHREE !!!!!
@sounaksaha14552 жыл бұрын
Hello ji Sir, aapke saath saath mera bhi consistency barkarar hai... Baas revision thora a66e se karna padega🥺
@bhawargujral35742 жыл бұрын
Great video bhaiya😍
@harikrushnasuhagiya39252 жыл бұрын
AWESOME VIDEO BANADI BHAIYA
@tejasshaha66292 жыл бұрын
Amazing video Bhaiya ❤❤
@satyajeetrai6529 Жыл бұрын
04-09-2023 LECTURE 51
@manavshah1844 Жыл бұрын
Very Great Explanation Sir Loved It
@TheBaljitSingh2 жыл бұрын
yeha hum privete me kyu likh rahe hai?? public me bhi ho shakta hai na declaration??
@ayushkushwaha1712 жыл бұрын
Thanks for the easiest explanation!
@poojayadav6952 жыл бұрын
awesome course bhaiya😄😄😄
@aryankr2 жыл бұрын
sab sahi char raha hai bhaiya
@KaushikSharma-c3q Жыл бұрын
Awesome explanation.
@RohitSingh-hc8yi Жыл бұрын
Bhot maja aa rah hai bhaiya
@shubhamkumarsingh8818 Жыл бұрын
thank you so much bhaiya
@be_happy84112 жыл бұрын
Net slow hai bhaiya motivation nhi, aaj complete krke hi shoduna🔥
@rahuls11472 жыл бұрын
Bhaiya ab leetcode ke qn kyu solve nahi karte
@roshanansy69012 жыл бұрын
test is important bhiya jo mene pa liya .thanks
@saurabhrajput74922 жыл бұрын
EXPLAINING IS SOO GOOD ....LOVE YOU BRO || RESPECT++;
@shristiiverma11062 жыл бұрын
Present Bhaiya 🥳🥳
@sagarsharma76712 жыл бұрын
Thanx bhaiya. Luv U 🤟
@vikashkumarvlogsnitj Жыл бұрын
superb video baiya
@namansharma442 жыл бұрын
Bhaiya please add handwritten notes on lecture 10 and above
@kundantarafdar36632 жыл бұрын
BHAIYYA NE KAHA "COMMENT KARNEKA TOH, KARNE KA...!"😁
@bhanuverma_iitbhu Жыл бұрын
bhaiya directly insert at head nhi kr skte kya ans node me??