Maximum Sum Triplet

Sdílet
Vložit
  • čas přidán 27. 09. 2021
  • Problem Description
    Given an array A containing N integers.
    You need to find the maximum sum of triplet ( Ai + Aj + Ak ) such that i LESS THAN j LESS THAN k and Ai LESS THAN Aj LESS THAN Ak.
    If no such triplet exist return 0.

Komentáře • 41

  • @bhaveshkumar6842
    @bhaveshkumar6842 Před 2 lety +11

    You are easily one of the best teachers I have ever come across online/offline. This was IMMENSELY helpful! Please cover all programming questions on InterviewBit because your in-depth explanations are of great help. Just a suggestion (i know it doesn't matter much though): if(i==n-1) will be checked for all n iterations of the first for loop. So, instead of that if condition inside the loop, you could have written right[n-1]=A[n-1] before the first for loop. Again, please cover all questions. It's immensely useful for me. Thank you for helping me out

    • @probabilitycodingisfunis1
      @probabilitycodingisfunis1  Před 2 lety +7

      Thank you Bhavesh, yes writing suffix array with the right[n-1] initialized before is better, and yes, I will try to cover all the questions from InterviewBit

    • @divyangdheer7292
      @divyangdheer7292 Před rokem +1

      jyada hogya bhai

    • @bhaveshkumar6842
      @bhaveshkumar6842 Před rokem +1

      @@divyangdheer7292 hmmm... Abhi mujhe bhi aisa lag raha hai. Par comment rehne deta hoon

  • @adeshchhajed8473
    @adeshchhajed8473 Před rokem +1

    Whenever I am stucking on problem coming on youtube & searching for your solution video
    Amazing solutions.

  • @yashasvprajapati6851
    @yashasvprajapati6851 Před rokem

    great video and to the point, great explanation, thank you for the video

  • @ShivamKumar-qv6em
    @ShivamKumar-qv6em Před 2 lety

    Great work . Very helpful content

  • @mohanavamsipidugu4419

    mam i love to watch your explaination ...great teaching.Thank you

  • @divy04
    @divy04 Před měsícem +1

    got the intuition by my own, just couldnt implement it, Once again beautiful explanation

    • @user-hp9kj8qt1h
      @user-hp9kj8qt1h Před 23 dny

      How did you build the intuition on your own?? I couldn't even think of it 😢

    • @user-hp9kj8qt1h
      @user-hp9kj8qt1h Před 23 dny

      I'm not able to build intuition to any question from my scratch. Always have to look for video. Can you suggest some tips pls

  • @bharathKumar-or6gd
    @bharathKumar-or6gd Před rokem

    great explanation mam good, hoping to expect more videos on leetcode questions haven't seen with good visual with step-by-step approach

  • @adityaverma4902
    @adityaverma4902 Před rokem

    really helpful, thank you very much di🙏🙏🙏

  • @vinodhkumar5329
    @vinodhkumar5329 Před 2 lety

    nice explaination mam! thank you

  • @gandhijainamgunvantkumar6783

    amazing explanation :)

  • @AnkitKumar-ys7vs
    @AnkitKumar-ys7vs Před 9 měsíci

    Thanks for the great explanation

  • @kapilpatel9379
    @kapilpatel9379 Před 10 měsíci

    I was not able to understand 100% but got the idea thanks

  • @anurag__pathak
    @anurag__pathak Před rokem +1

    The girl behind her is like sone do yrr 🤣🤣

  • @prakhyat2001
    @prakhyat2001 Před rokem

    Thanks a lot 🙌🏻

  • @harikalakshmisainannapanen181

    thankyou so much di🙏🙏

  • @chandraprakashsahu8557

    there are various explanation of every problem in youtube but i like you and your video 😁
    btw
    Nice explanation 👌👌

  • @KD-xi9wu
    @KD-xi9wu Před 2 lety +1

    But this code doesn't work for -ve numbers array isn't it???????

  • @techworld7658
    @techworld7658 Před rokem

    why cant we sort the whole array and calculate sum -of last 3 index?

  • @sakshamsrivastava6280
    @sakshamsrivastava6280 Před 2 lety +1

    great video, but i have a question here , if we are taking just smaller on the left of the current element while traversing the main array , then we are making the suffix array, if for left we are taking the lower bond, shouldn't for the right largest we should be taking the upper bound.
    or we are taking the right most greatest element in the form of suffix array , why are not doing the prefix array as well for the left side also.
    any reasons would be appreaciated.
    thanks.

    • @monikaraut5266
      @monikaraut5266 Před 2 lety

      For a element, we want to find greatest element on right side, hence we are taking suffix array…
      But it’s not the same case for finding element from left side..
      Here ,we are not searching for smallest element on the left side, but we are searching for greatest element on left side which is less than element .
      Hence using suffix array will not work for left side

    • @monikaraut5266
      @monikaraut5266 Před 2 lety +1

      Also if you take suffix array for left side..it may give element which is more than the middle element… this will violate the constraints given in the problem..
      Constraint:- Ai

  • @rajathkumar3822
    @rajathkumar3822 Před 2 lety +1

    Apka laptop ka ram kithna hoga.
    Ye tabs enthe kule he😂.
    Ryzen ka he kya or Intel i5 11gen.

  • @basicGyaan07
    @basicGyaan07 Před 2 lety +2

    someone is there in your background :)

  • @sanketmane5838
    @sanketmane5838 Před rokem

    great explanation mam

  • @devanshdixitmusicallyyours3885

    kindly provide code as well which u explain in video , it will be helpful for us.

  • @anuruddhtiwari7753
    @anuruddhtiwari7753 Před 2 lety

    Ma'am why you not solving potd daily,we daily waiting your video

  • @Idukhan-jj9kc
    @Idukhan-jj9kc Před 2 lety

    👍👌

  • @systemforge
    @systemforge Před 2 lety

    woah...

  • @jigarjoshi9198
    @jigarjoshi9198 Před rokem

    we can do it in O(n ) by sorting array and fetching last three elements sum as answer?

  • @Idonnoknow2246
    @Idonnoknow2246 Před 2 lety +1

    how to contact you