Babbar bhaiyya... I love you... Koii apna bhi itna help nhi karta jitna aap kar rhe ho.... Bhagwan aapko meri ummar bhi de de... Legend and GOAT....
@yashsonune43912 жыл бұрын
Glad I have completed 1/3 of the series, and still continuing.
@parthdeshwal44199 ай бұрын
how long did it take you ?
@iamvishnuranjan2 жыл бұрын
Bhaiya 1 month me (1- 49 )lecture 😍 what a course..
@tjstar3902 жыл бұрын
BOTH Questions have unique concepts and bhaiya explain it very well,Thanks bhaiya.
@Anmol-h8z6 ай бұрын
at 41:15 while inserting a node between two nodes we can use : curr1->next=curr2; curr2=curr2->next; curr1=curr1->next; curr1->next=next2; and also why we are checking for next1->data >curr2->data > curr1->data we could just check with next1 only as we know we start with element with smallest value any value will be greater than or equal from starting node and then going further in list if curr2 is inserted and then new curr2 value will definitely greater than previous one
@yashparalikar05 Жыл бұрын
Your teaching and your explanations are absolutely exceptional!!!
@harshitkumar1972 жыл бұрын
I coded the 2nd one merge two sorted array by myself. i looked at ur approach discussion and did by myself. thanks for the giving me the confidence
@therealartist911 ай бұрын
in which company you are working ??
@priyanshpatel20782 жыл бұрын
20:00 We can Simply Handle it by using this steps p3->next=NULL; p2->next=twoHead->next; p1->next=oneHead->next;
@devanshusahoo2 жыл бұрын
Thank you so much for your lovely videos, you really make understanding the concepts a cakewalk! Glad to be your student.
@divyareddy76222 жыл бұрын
why cant zero and two 's list be empty here? he only took the case when 1's list is empty
@Roshanhoro1232 жыл бұрын
thanks bhaiya for bringing all such good questions in this course and hats off to your efforts...aap itne busy hoke bhi regular videos daal rhe ho isse motivation milta hai ki chahe kitne bhi busy rhe humlog cllg exams me tb bhi hum pdhai krre... Thanks bhaiya...Keep smiling bhaiya bht suit krta hai aaapar..
@tusharmukherjeeju-cse57732 жыл бұрын
Can't believe that someone dislike this video ! 🙂 💔 If you buy a course which takes from you 20k that course never give you that kind of explanation . Love from Kolkata ❤️🙌
@divyareddy76222 жыл бұрын
why cant zero and two 's list be empty here? he only took the case when 1's list is empty
@visheshkaran70832 жыл бұрын
@@divyareddy7622 because even if two's or zero's list are empty they will be null and onetail->next will be null so it won't make any difference.
@durgashreenv842610 ай бұрын
35:00 Explanation was just amazing, thank you so much!
@RajveerKaur-ze1ll Жыл бұрын
to check for the case when both elements have one one element, instead of adding a new if condition at beginning, we can also move the "if (next1==NULL)" condition outside the while loop, then also answer is correct, hope this helps.
@prashantbpkumar510 Жыл бұрын
Exactly
@tanishsinghal1879 Жыл бұрын
yeah boyh
@unboxtheuniverse53362 жыл бұрын
Wahhh bhaiya 💥😃😃 DSA ki ab Video na dekhu to din productive nhi lagta 😃 Bhaiya plz *"5 Month Internship Strategy Series lao with DSA busted course as resource"* (for 2nd year students)🥺
@suranjandhara75352 жыл бұрын
Wow 😳😳😳😳😳 nya video aa gya..... Maza aa gya .... Abhi hi dekh lunga....🥰🥰🥰🥰🥰🥰🥰❤️❤️❤️❤️❤️❤️❤️❤️❤️🌷🌷🌷🌷🌷🌷🌷🌷🌷 Thanku bhaiya .... ❤️❤️❤️❤️
@anmolkumar01 Жыл бұрын
at 55:44 , i think we don't need to add extra case when there is only one element in list one instead what we can do is - we can simply write that condition of if(next1== NULL and curr2 != NULL){ curr1 -> next = curr2; } it will take care of case at 55:44 as well as previous case when first list finish and second list still has some element and please feel free to to correct me if i am wrong ,
@vmstudy9965 Жыл бұрын
Mjaa aa gya bhiya aaj to🎉 Finally I solved this problem myself. After watching this video
very good explanation . now i am understanding everything . you are a very good teacher and motivator also, please keep it up 😅😅
@115GAJBHIYESHREYA4 ай бұрын
Thank you for providing an amazing series.
@KaushikSharma-c3q Жыл бұрын
Awesome explanation.
@saswatighosh31622 жыл бұрын
It was lit 🔥🔥🔥🔥🔥🔥🔥
@avibirla98632 жыл бұрын
Maza aa gaya bhaiya kya question tha merge wala 👍👍Or last ka edge case 👍♥️
@laksheybanga81062 жыл бұрын
Bhaiya I m your biggest fan! bas jldi se phase 2 khtm krdo bhaiya!
@anuragpandey81652 жыл бұрын
24:52 insertAtTail function kaha defined hai??
@060_jiteshtripathi6 Жыл бұрын
bhaiya maza hi aagya, kya mast samjhate ho
@anuragpatel778711 ай бұрын
hnji this is anurag patel Lec 49 completed successfully ✅
@Josuke2177 ай бұрын
My approach: SC: O(n) , TC: O(n) For 0,1,2. class Solution { public: ListNode* sortList(ListNode* head) { vector res; ListNode* temp = head; while(temp != nullptr) { res.push_back(temp->val); // Store value of current node temp = temp->next; // Move to next node } sort(res.begin(),res.end()); // Sort the vector // Now convert the vector into the sorted linked list int index=0; temp = head; while(temp != nullptr) { temp->val = res[index++]; temp = temp->next; } return head; } }
@@ayushburnwal9992 search love babbar dsa sheet download
@itz_arman_official__2 жыл бұрын
Thanks for your amazing content and your consistency is awesome bhaiya.
@udaypratapsingh89232 жыл бұрын
bhaiyaa ye hashing or heap bhi cover krva dena ... jab bhi ye sunta hui dar sa lagta hai 😅😅😅
@mittalji9195 ай бұрын
i used below merging algo and it is also working without any if condition nodeZTail->next = nodeO->next; delete(nodeO); nodeOTail->next = nodeT->next; delete(nodeT); head = nodeZ->next; delete(nodeZ); return head;
thank you bhaiya , placement ke baad aapko party meri taraf se .
@RohitRana-tz2lr2 жыл бұрын
Thank you so much bhaiya for training our mind in solving a different variety of questions... hats off to you bhaiya...keep it up
@RohitSingh-hc8yi Жыл бұрын
2nd Problem was awesome!
@anmolkumar01 Жыл бұрын
my approach for 1st question was that i just sorted it in two go without using extra space and in O(n) firstly : sort all the ones , if one present then remove it and link it to the head of list and update the head secondly : sort all the zeros , if 0 is present then remove it and link it to the head of list and update the head my code : void sort(Node* &head , int val){ Node* temp = head; while(temp->next != NULL){ if(temp->next->data == val){ Node* x = temp->next; temp->next = x->next; x->next = head ; head = x; } else{ temp = temp->next; } } } Node* sortList(Node *head){ if(head == NULL or head->next == NULL) return head; sort(head , 1); sort(head , 0); return head; } if there is any suggestion or correction then please feel free to correct me and above code is also accepted by the codestudio
@Pawankumar-i8c6 ай бұрын
thank you so much bhiaya for these precious lecture
@lalitbisht8381 Жыл бұрын
merge wala question krke maza aa gya!!!!!!!!!!
@kanikagupta28062 жыл бұрын
concept++; understanding +++++++++; thankyou so much babbar bhaiya maza hi aagya..
@divyareddy76222 жыл бұрын
why cant zero and two 's list be empty here? he only took the case when 1's list is empty
@kanikagupta28062 жыл бұрын
@@divyareddy7622 beacuse 1's list is connecting 0's and 2's list. If 1's list is empty then approach discussed without if condition won't work. Hope it helps.
@ayushp44712 жыл бұрын
BEST explaination as always 🔥🙌
@anuptewary30162 жыл бұрын
Present bhaiya with lot's of Josh
@saurabhmalviya1002 жыл бұрын
Kya baat hai mazaa aa gaya .josh is high and it should be High 😂😂😂
@pahaljain92092 жыл бұрын
Hat's Of bhaiya
@ch0c0_1 Жыл бұрын
mza aagya bhai . Nice explanation
@RohitSingh-hc8yi Жыл бұрын
Thankyou for such a quality content
@anuragpandey81652 жыл бұрын
37:10 Just call sortTwoList(second, first) thats it.
@justarandomguy61062 жыл бұрын
How's that possible
@samsmith39612 жыл бұрын
concept finally samajh aa gya
@aishavkhandelwal82712 жыл бұрын
Mst ques tha dimag khul diya pura !! thx
@tanbirsarkar2640 Жыл бұрын
sabse maza to linked list mai arha hai,,mast hai bahut,,basss pyar hojata hai
@abhishekhsinha1551 Жыл бұрын
glad for your kind help moye moye !!! love from IITG
@neerajgarg90962 жыл бұрын
EAGERLY WAITING FOR THIS LECTURE LOVE U BABBAR BHAIYA❤❤
@Coder_DhruvArora2 жыл бұрын
26:03 space complexity O(n) nahi hogi? As hum ek new list bana rahe hai
@devanshbatra3082 жыл бұрын
Exactly, I am also confused with this.
@RitikSingh-oh3sj2 жыл бұрын
merge walai second question mai maga aa gaya bhaiya
@garimasharma276 Жыл бұрын
NEVER have I ever got such a crush on some one!! your way of teaching is quite captivating.
@shripandey41202 жыл бұрын
Bhaiya, 27:05 pr space complexity o(1) kse hogi, humne jo alag se three linked list bnayi hai uska space ?
@alokranjan31852 жыл бұрын
totatly different explanation bhaiya, thanks
@yuvrajdhamija5592 күн бұрын
1st question mein dummy nodes bnaane ki zaroorat hi kya thi?? uske bina bhi to ho jaayega code
@riyadhossain1706 Жыл бұрын
Became a fan of your learning style...........
@-akashkumarsingh2 жыл бұрын
Mere dekhne ki consistency se jyadaa toh video aane ki hai..
@ayushp44712 жыл бұрын
Your efforts BHAIYAA🔥🔥🙌🙌
@sundrmm0350 Жыл бұрын
Bhiyaaaa!!! Uh beauty🙇🏻♂️
@adityaraj-zm7zk2 жыл бұрын
bhai it is very good question and you really very good explained , fanstically you are very good teacher
@theOmKumar2 жыл бұрын
Explanation + Minor adjustment to improve q1 while addressing memory leak! // // merge 3 sublist (assuming one's list is not empty) zeroTail -> next = oneHead -> next; oneTail -> next = twoHead -> next; twoTail -> next = NULL; return zeroHead -> next; //merge 3 sublist (Note: if 1st list is empty, then we can't connect zero list with two list using previous code) if (oneHead -> next != NULL) //one's list is not empty, so we'll connect 0 list with one { zeroTail -> next = oneHead -> next; oneTail -> next = twoHead -> next; } else zeroTail -> next = twoHead -> next; //one's list is empty, so we'll connect 0 list with 2s directly; twoTail -> next = NULL; //this will end the LL. return zeroHead -> next; // //to prevent memory leak, due to allocation of dummy node so we need to delete it. // Node* ans = zeroHead -> next; // delete(zeroHead); // delete(oneHead); // delete(twoHead); // return ans; }
@lakshsinghania Жыл бұрын
exactly! kudos
@arpitghura Жыл бұрын
this is what I am supposing as the oneHead does not have any one node, so if we put it outside it will create an additional LL which is of no use. So, we can put the line no. 60 inside the if condition to prevent the creation of additional LL.
@tanishsinghal1879 Жыл бұрын
shi hai bhai agr tu comment m nhi likhta ye sb to mai ye sochta syad m hi glt hun
@prashantmaurya68682 жыл бұрын
Fantabulous explanation....
@sachitdhamija18842 жыл бұрын
bhaiya acha tha merge 2 sort L.L samjaha but sort 0,1,2 thoda problem hua but 2 baar aur dekho ga toh samjho ga lage raho
@ritikamehta97912 жыл бұрын
Great work sir!! mza aa rha hai ab pdhne me💯
@rachit_joshi10 ай бұрын
Thank You So Much BHRATA SHREE !!!!!
@itzheavem44512 жыл бұрын
very well explained Mzaa aa gya
@ProgrammingPirates2 жыл бұрын
va bhayya moj kar di 🤩🤩🤩🤩🤩
@satvikshukla5962 жыл бұрын
Thank you sir 🙏
@vaibhavraj2847 Жыл бұрын
bhaiya aapne jo array me merge and sort wala concept se padhaya tha ussejyada easy se ho gaya!! #include #include using namespace std; class node { public: int data; node *next; node(int data) { this->data = data; this->next = NULL; } ~node() { int value = this->data; if (this->next != NULL) { next = NULL; } delete next; cout next = curr2; tail = curr2; curr2 = curr2->next; } } while (curr1 != NULL) { tail->next = curr1; tail = curr1; curr1 = curr1->next; } while (curr2 != NULL) { tail->next = curr2; tail = curr2; curr2 = curr2->next; } head = head->next; return head; } int main() { node *head1 = NULL, *head2 = NULL; node *tail1 = NULL, *tail2 = NULL; insert(1, head1, tail1); insert(3, head1, tail1); insert(5, head1, tail1); insert(8, head1, tail1); insert(2, head2, tail2); insert(4, head2, tail2); insert(5, head2, tail2); insert(8, head2, tail2); insert(10, head2, tail2); print(head1); print(head2); node *ans = merge_two(head1, head2); print(ans); }
@amanmehra43682 жыл бұрын
no words for you bhaiya ❤❤❤
@theOmKumar2 жыл бұрын
Simpler Approach for Q2. , we can also do this without dummy node by putting head at right place first , and then simply traversing and joining smaller val data. ListNode* mergeTwoLists(ListNode* list1, ListNode* list2) { if (!list1) return list2; if (!list2) return list1; ListNode *ans = new ListNode(-1); ListNode *temp = ans; while (list1 && list2) { if (list1->val < list2->val) { temp -> next = list1; temp = list1; list1 = list1 -> next; } else { temp -> next = list2; temp = list2; list2 = list2 -> next; } } while (list1) { temp -> next = list1; temp = list1; list1 = list1 -> next; } while (list2) { temp -> next = list2; temp = list2; list2 = list2 -> next; } return ans -> next; }
@kunalmodiart2 жыл бұрын
i watched the solution given in the video then went on to code the Q by myself with my approach .. then i came in comments to add my code and i found your code which is literally similar to mine 😂 what a coincidence
@antrikshgupta19642 жыл бұрын
void sort(Node* &tail, Node* &head){ tail->next = head; head = head->next; tail = tail->next; } //Function to merge two sorted linked list. Node* sortedMerge(Node* head1, Node* head2) { Node* head = new Node(-1); Node* tail = head; while(head1!=NULL and head2!=NULL){ if(head1->data data){ sort(tail,head1); } else{ sort(tail,head2); } } while(head1!=NULL){ sort(tail,head1); } while(head2!=NULL){ sort(tail,head2); } return head->next; }
@adityachauhan59132 жыл бұрын
@codeHelp bhaiya ek dummy node le kr compare aur direct connect karte chale jaaye last me dummy ka nxt return kar dnge
@satyamjha-codeindwala6666 Жыл бұрын
Merge 2 Sorted Linked Lists || Sort 0s, 1s and 2s in Linked List🥰🥰🥰🥰🥰🥰🥰🥰
@kundanmali2405 Жыл бұрын
thank you for providing such great content.
@pahaljain92092 жыл бұрын
Present sir
@muneebjaved39402 жыл бұрын
Thank you so much bhayia Concept ++++++; Explanation ++++++++;
@suvigyabasnotra73782 жыл бұрын
25:09 Now this code is giving Runtime Error (SIGSEGV) on each of the 3 test cases! Below is what I typed: void insertAtTail(Node* &tail, Node* curr){ tail -> next = curr; tail = curr; } Node* sortList(Node *head) { Node* zeroHead = new Node(-1); Node* zeroTail = zeroHead; Node* oneHead = new Node(-1); Node* oneTail = oneHead; Node* twoHead = new Node(-1); Node* twoTail = twoTail; Node* curr = head; // create separate linked lists for 0s, 1s and 2s. while(curr != NULL){ int value = curr -> data; if(value == 0){ insertAtTail(zeroTail, curr); } else if(value == 1){ insertAtTail(oneTail, curr); } else if(value == 2){ insertAtTail(twoTail, curr); } curr = curr -> next; } // merge 3 sublists //Case 1: linked list isn't empty if(oneHead -> next != NULL ){ zeroTail -> next = oneHead -> next; } else{ // list is empty zeroTail -> next = twoHead -> next; } oneTail -> next = twoHead -> next; twoTail -> next = NULL; // setup head head = zeroHead -> next; // deleting dummy nodes delete zeroHead; delete oneHead; delete twoHead; return head; }
@04_abhishekpandey372 жыл бұрын
bro Node* twoTail= twoHead hoga.
@anuragpandey81652 жыл бұрын
bro initialization of twoTail is not correct. It should be { Node* twoTail = twoHead; } and not { Node* twoTail = twoTail; }
@suvigyabasnotra73782 жыл бұрын
@@anuragpandey8165 Checked the code at least thrice but couldn't find the error myself. Kamal karte hain Pandey ji!
@suvigyabasnotra73782 жыл бұрын
@@04_abhishekpandey37 @Anurag Pandey Checked the code at least thrice but couldn't find the error myself. Kamal karte hain Pandey ji!
@dhhforlife88892 жыл бұрын
@@suvigyabasnotra7378 🤣🤣
@muhammadsuleman8936 Жыл бұрын
Merge 2 Sorted Linked Lists || Sort 0s, 1s and 2s in Linked List
@bhawargujral35742 жыл бұрын
Great Video as usual.. Quality content
@palaksolanki80372 жыл бұрын
Thank you soooo much bhaiya for ur consistent efforts
@prathmeshparteki10162 жыл бұрын
Thanks for this great content bhaiyya .. 🤩
@jatingarg18972 жыл бұрын
Maza Aaayaa bhai karke !
@shubhrasharma7282 Жыл бұрын
bhai... 2nd waala question leetcode pr TLE de rha hai..... aap aadhi conditions skip kr dete ho.....phir khud se condition add kr krke dimaag khraab hota hai
@cg.yamangaming46322 жыл бұрын
Bhaiya code studio me aap coding krte ho to list enter Karne vaala part samgh Ni as RHA kaise krna hai
@B-NikhilRichhariya Жыл бұрын
aap mehnat krte ho na wo dekh ke aur mehnat krne ka mn krta hai
@anshulsingh12652 жыл бұрын
done bhaiya
@prathamSuthar-cy6hs Жыл бұрын
Bhaiya yeh jo notes likhne ke liye software waparte ho yeh konsa he ??