2058. Find the Minimum and Maximum Number of Nodes Between Critical Points | Greedy | Linked List

Sdílet
Vložit
  • čas přidán 6. 09. 2024
  • In this video, I'll talk about how to solve Leetcode 2058. Find the Minimum and Maximum Number of Nodes Between Critical Points | Greedy | Linked List
    Let's Connect:
    📱Discord (Join Community) : / discord
    📝Linkedin: / aryan-mittal-0077
    📸 Instagram: / codewitharyanbhai
    💻 Twitter - / aryan_mittal007
    🤖 Github: github.com/ary...
    About Me:
    I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
    ✨ Timelines✨
    ✨ Hashtags ✨
    #programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Komentáře • 14

  • @ARYANMITTAL
    @ARYANMITTAL  Před 2 měsíci +15

    Okay July easy going so far, means next week is gonna be 🤐, what do you guys think 💭

  • @kgjr.6224
    @kgjr.6224 Před 2 měsíci +2

    hello bhai I have used your tips and got job. Thanks brother.

  • @sanukumar256
    @sanukumar256 Před 2 měsíci

    Great Explanation 🤩

  • @codingkart245
    @codingkart245 Před 2 měsíci

    great explanation, I think there were some problem with the mic while you were recording this.

  • @naamnhibataunga5897
    @naamnhibataunga5897 Před 2 měsíci

    my solution:
    similar approach
    class Solution {
    public:
    vector nodesBetweenCriticalPoints(ListNode* head) {
    vector ans(2,-1);
    ListNode *slow=new ListNode();
    ListNode *curr=head;
    ListNode *fast=head->next;
    if(!fast || !fast->next) return ans;
    int firstcritical=-1;
    int lastcritical=-1;
    int mindistance=INT_MAX;
    int count=1;
    slow=curr;
    curr=fast;
    fast=fast->next;
    while(fast){
    if((curr->val>slow->val && curr->val>fast->val) || (curr->valval && curr->valval)){
    if(firstcritical==-1){
    firstcritical=count;
    }
    else{
    mindistance=min(mindistance,count-lastcritical);
    ans[1]=count-firstcritical;
    ans[0]=mindistance;
    }
    lastcritical=count;
    }
    count++;
    slow=curr;
    curr=fast;
    fast=fast->next;
    }
    return ans;
    }
    };

  • @Mehul_14403
    @Mehul_14403 Před 2 měsíci

    @15:21 shouldn’t ans[1] be equal to max of ans[1], id-first rather than max of ans[0], id-first??

  • @karthikmadan
    @karthikmadan Před 2 měsíci

    aryan bhai check krlijiye pls goldman ka issue aapse mail kr rkha

  • @manishgaming4638
    @manishgaming4638 Před 2 měsíci

    Easy Question if u are familiar with linked list.
    Solved on my own

  • @sabbyasachichakraborty1824
    @sabbyasachichakraborty1824 Před 2 měsíci

    first comment