Smallest Absolute Difference gfg problem of the day | Leetcode 719. Find K-th Smallest Pair Distance

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

КОМЕНТАРІ • 51

  • @probabilitycodingisfunis1
    @probabilitycodingisfunis1  2 роки тому +4

    int sliding(int diff,int arr[],int n)
    {
    //how many pairs have absolute diff less than or
    //equal to diff
    int j =0;
    int count=0;
    for(int i=1;idiff)j++;
    count+=i-j;
    }
    return count;
    }
    int kthDiff(int arr[], int n, int k)
    {
    sort(arr,arr+n);
    int high = arr[n-1]-arr[0];
    int low =INT_MAX;
    for(int i=1;i

    • @mohammadkaif8143
      @mohammadkaif8143 9 місяців тому

      Pinned by Code with Alisha
      @probabilitycodingisfunis1
      1 year ago (edited)
      int sliding(int diff,int arr[],int n)
      {
      //how many pairs have absolute diff less than or
      //equal to diff
      int j =0;
      int count=0;
      for(int i=1;idiff))j++;
      if(j==i) continue;
      count+=i-j;
      }
      return count;
      }

  • @moneybansal2791
    @moneybansal2791 Рік тому +7

    I could appreciate for one thing that u always teach tough problems, hats off to u

  • @abhaydeepsharma5027
    @abhaydeepsharma5027 Рік тому +3

    I dont know how could I thank you , I litterally read others solutions on LC for 1 hr , watched 4-5 videos on this then I got this ... Perfectly explained and the detailed dry run was very helpful

  • @DheerendraSingh-u2m
    @DheerendraSingh-u2m 2 місяці тому

    one of the most beautifully explained solutions❤❤❤

  • @suchithreddy733
    @suchithreddy733 2 роки тому +1

    Brilliant explanation and dry run of the case as usual. Thanks for this

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

    Thanks for in detail explanation ❤

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

    Superb Explanation!!

  • @ranchhordaschaanchad2623
    @ranchhordaschaanchad2623 6 місяців тому +1

    Your explanations are great. Thanks a lot!

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

    Beautiful explanation and it was easy to understand.

  • @Rizwankhan-ts3gk
    @Rizwankhan-ts3gk Рік тому

    very clearly explanation, thank you very Alisha for sharing

  • @aayushmaurya1672
    @aayushmaurya1672 2 роки тому +2

    Thanks for your awesome explanation, I was stuck in this problem since morning.

  • @arijitdey8419
    @arijitdey8419 2 роки тому +1

    Again a great explaination of a relatively tougher problem,thanks a lot mam..Keep making such wonderful videos

  • @dhananjoydey1337
    @dhananjoydey1337 2 роки тому +1

    Thank you so much . I was not able to find any approach for this problem

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

    nice explanation

  • @kaustubhdwivedi1729
    @kaustubhdwivedi1729 2 роки тому +4

    Total numbers of pairs will be nC2 = n * (n-1)/2 = 4 * 3 / 2 = 6

  • @pateladarsh1463
    @pateladarsh1463 2 роки тому

    Thank you so much for this type of very helpful videos ...

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

    Nice explanation. Thank you.

  • @Rajat_maurya
    @Rajat_maurya 2 роки тому

    Thank you good explaination

  • @shatulbansal4756
    @shatulbansal4756 2 місяці тому

    Hey Alisha, a great solution!!
    1 QUERY: In this Binary search approach that you have followed, lets suppose you get the required answer but is it necessary that the difference that you get in answer will be actually a difference between a pair of values of input array??
    Like it may be possible that the diff that we got in ans using binary search might not a gettable using diff of any 2 array numbers....

  • @deepankarjain4668
    @deepankarjain4668 2 роки тому

    Thank You So Much for the Explanation, This is indeed the best approach one can explain, Major Appreciations!!

  • @shantanukumar4081
    @shantanukumar4081 2 роки тому +1

    Great explanation !!! ☺️☺️☺️

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

    well explained :)

  • @jabedhasan21
    @jabedhasan21 Рік тому

    Nicely explained👍

  • @mr_blaze62
    @mr_blaze62 2 роки тому

    Thank you ma'am. Nicely explained

  • @kunalbahirat7795
    @kunalbahirat7795 2 роки тому

    Thanks

  • @litegamertech1723
    @litegamertech1723 2 роки тому

    Awesome explanation sister was able to learn a lot keel doing more videos🔥👍

  • @Idukhan-jj9kc
    @Idukhan-jj9kc 2 роки тому

    Awesome example

  • @NaveenKumar-os8dv
    @NaveenKumar-os8dv 2 роки тому

    there is another approach for this problem (Trial and Error was it?) , can you please explain with that approach too?

  • @vimalk2661
    @vimalk2661 2 роки тому

    Great explanation! thank you.

  • @03_abhishekchoubey42
    @03_abhishekchoubey42 2 роки тому

    Such a great explanation mam
    Really great
    Hatts off too you mam🙌🙌😍

  • @akshanshvijoy
    @akshanshvijoy 2 роки тому

    was waiting for this video !

  • @amishjaiswal3929
    @amishjaiswal3929 2 роки тому

    Hii, can you please explain: the mid we are calculating will always be the difference of any pair.

  • @Nirala_414
    @Nirala_414 2 роки тому

    little long video, but you have explained really well , thanks

  • @dhananjoydey1337
    @dhananjoydey1337 2 роки тому

    can you please upload today's POTD solution

  • @siddhantsrivastava4048
    @siddhantsrivastava4048 2 роки тому

    The total number of possible pairs are: (n*(n-1))/2

  • @shuvbhowmickbestin
    @shuvbhowmickbestin Рік тому

    how come is n = 3?

  • @basvarajsb3857
    @basvarajsb3857 Рік тому

    There is no real performance hit when you make 0 as the lower bound of your solution space in the binary search. Better cognitive complexity of the code.

  • @sushmitagoswami2033
    @sushmitagoswami2033 2 роки тому

    Your explanation is great. But kindly don't repeat basic stuffs twice. Would be great if you keep it little shorter. Just a suggestion. But You are excellent.

  • @priyanshuTrip
    @priyanshuTrip 2 роки тому

    Brute Force TC will be : N^2(log N)🙂

  • @ruchi315
    @ruchi315 11 місяців тому +1

    Not a good explaination

  • @vinamrasangal8436
    @vinamrasangal8436 6 місяців тому

    sexy explaination