2181. Merge Nodes in Between Zeros | Linked List | How to Write Linked List Code

Поділитися
Вставка
  • Опубліковано 28 жов 2024

КОМЕНТАРІ • 24

  • @Yashcolab
    @Yashcolab 3 місяці тому +12

    0:40 i was not prepared for that

  • @coderunner743
    @coderunner743 3 місяці тому +7

    thanks, bro because of you I got placed in Zoho.

    • @ARYANMITTAL
      @ARYANMITTAL  3 місяці тому +3

      Congratulations man ❤️🫡, big big Congratulations 🥳🔥

    • @coderunner743
      @coderunner743 3 місяці тому

      @@ARYANMITTAL thanks bro

  • @worldofgaming748
    @worldofgaming748 3 місяці тому +1

    0:40
    "Bro is getting personal day by day"

  • @NoName-hd7ok
    @NoName-hd7ok 3 місяці тому +2

    Bro maine cf pe just expert touch kiya , dev me mern kiya h bs tutorial dekh kar , project bhi yt se chhapkar blog app bnaya h , intern ke liye next 1 month me kya krna chahiye , if from an avg NIT?

    • @arnavkaul7827
      @arnavkaul7827 3 місяці тому

      make a project now but on your own think like a dev -read docs(verry underrated tip imo), utilise resources like stack overflow etc implement if it doesnt work repeat the process.. And bhai expert pahuchne pe kitna time laga and usme mujhe thode tips dede

    • @NoName-hd7ok
      @NoName-hd7ok 3 місяці тому

      @@arnavkaul7827 ok bhai , nov se seriously kr rha tha cp

  • @bhamidipatisatwik1165
    @bhamidipatisatwik1165 3 місяці тому

    what about the case where there are two consecutive 0 nodes? is this case being handeled as there shouldn't be 0s in the resulatant list.

  • @KarthikMadan-x5c
    @KarthikMadan-x5c 3 місяці тому

    @karthikmadanaryan bhai goldman me apply krna rehgya please kuch help kr skte ho?

  • @sanebrain3083
    @sanebrain3083 3 місяці тому +3

    i want to practice this list type of questions more like where i get to practice while complicated writing of code is there what to do can you give list of such question

    • @ARYANMITTAL
      @ARYANMITTAL  3 місяці тому +2

      This will help, it has 20 very nice problems - ua-cam.com/play/PLEL7R4Pm6EmABenswDvaCGhiLNlExFKM8.html

  • @naamnhibataunga5897
    @naamnhibataunga5897 3 місяці тому

    this is my code:
    i think it is better because i didn't have to think of any edge cases.
    class Solution {
    public:
    ListNode* mergeNodes(ListNode* head) {
    ListNode *dummy=head;
    ListNode *curr=dummy;
    int sum=0;
    ListNode *temp=head;
    temp=temp->next;
    while(temp){
    if(temp->val!=0){
    sum+=temp->val;
    temp=temp->next;
    }else{
    if(sum!=0){
    curr->next=new ListNode(sum);
    curr=curr->next;
    }
    sum=0;
    temp=temp->next;
    }
    }
    ListNode *ans=dummy->next;
    delete dummy;
    return ans;
    }
    };

  • @karthikmadan
    @karthikmadan 3 місяці тому

    aryan bhai goldman me apply krna rehgya please kuch help kr skte ho?

  • @PushkarVarshney-d1d
    @PushkarVarshney-d1d 3 місяці тому

    whose company ask these question

  • @karthikmadan
    @karthikmadan 3 місяці тому

    aryan bhai kuch help krdo Goldman ki date nikl gyi pls bhai

    • @ARYANMITTAL
      @ARYANMITTAL  3 місяці тому

      Link bhejo bro job opening ka linkedin pr, recruiter ka email bhejte hai, its a long story why I would be recommending to apply via cold email to recruiter !!

  • @sagaragrawal6315
    @sagaragrawal6315 3 місяці тому

    class Solution {
    public:
    ListNode* mergeNodes(ListNode* head) {
    ListNode* dummy=new ListNode();
    ListNode* temp=dummy;
    while(head->next!=nullptr){
    dummy->next=head;
    head=head->next;
    dummy=dummy->next;
    while(head!=nullptr&&head->val!=0){
    dummy->val+=head->val;
    head=head->next;
    }
    }
    dummy->next=nullptr;
    return temp->next;
    }
    };
    this is also o(1) space na

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 3 місяці тому

    ListNode mergeNodes (ListNode head){
    ListNode p1=head.next,p2=p1;
    while(p2!=null){
    int sum=0;
    while(p2!=null&&p2.val!=0){
    sum+=p2.val;
    p2=p2.next;
    }
    p1.val=sum;
    p2=p2.next;
    p1.next=p2;
    p1=p1.next;
    }
    return head.next;
    }
    🎉❤

    • @ARYANMITTAL
      @ARYANMITTAL  3 місяці тому

      Awesome Daya Shankar 🫡❤️

  • @karthikmadan
    @karthikmadan 3 місяці тому

    aryan bhai goldman me apply krna rehgya please kuch help kr skte ho?

  • @karthikmadan
    @karthikmadan 3 місяці тому

    aryan bhai goldman me apply krna rehgya please kuch help kr skte ho????