Find the triplet that sum to a given value | Q28 | Love Babbar DSA Sheet

Sdílet
Vložit
  • čas přidán 11. 11. 2020
  • #competitiveprogramming #dsasheet #interviewpreparation
    In this video I have solved the 28th problem of the sheet i.e. Find the triplet that sum to a given value.
    String question Playlist = • Love Babbar DSA 450 Qu...
    Array question Playlist = • Love Babbar DSA 450 Qu...
    Love Babbar DSA Sheet : drive.google.com/file/d/1FMdN...
    Hope you like it. Comment if you have any doubt.
    LIKE | SHARE | SUBSCRIBE

Komentáře • 37

  • @uditbhaskar9158
    @uditbhaskar9158 Před 3 lety +12

    JUST A SMALL TRIBUTE FROM MY SIDE, YOU ARE DOING A GREAT JOB PLS DON'T QUIT BECAUSE OF VIEWS , TODAY AND TOMORROW YOU GUYS WILL RISE & SHINE.

  • @tarunmehta8448
    @tarunmehta8448 Před 3 lety +1

    Thank you for the explanation, very nice. Please keep doing the great work. 🙏🙏
    God bless you

  • @VishalKumar-pk9ek
    @VishalKumar-pk9ek Před 3 lety +1

    bahut sahi bhai 😍😍😍
    bas ek request hai aapke group me jo baaki members hai unhe bhi saare approaches ke solutions dikhane ko kehna
    well hard copy se code samajhna super simple ho jaata hai ishliye
    👍👍

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

    Please Include the logic for the Test cases in which elements in the array can repeat .

    • @Coding_Student144
      @Coding_Student144 Před rokem

      In that test case they know this logic will be going to fail

  • @kapildubey7249
    @kapildubey7249 Před 3 lety +1

    Nice bhai , well explained this problem , please explain the same way all :)

  • @azharbeg4267
    @azharbeg4267 Před 3 lety

    which sol is best, 2 pointer techinque or hashing for the placement purpose?

  • @mayurpatil6914
    @mayurpatil6914 Před 3 lety

    Very well explained

  • @bestexplainer4831
    @bestexplainer4831 Před 2 lety +5

    Sir 3rd approach ki Time Complexity O(n Log(n) ) hogi because we use sort() function. Kya mai sahi kah raha hu

    • @division-gaming
      @division-gaming Před 2 lety

      n^2 logn honi chaiye shayd

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

      It would be n2 only kyu ki hum code me usko kitni jyada complexity lagti h wo dekhte h so nlogn is less than the two loops running which gaves the time complexity of n2 that's why overall timecomplexity =n2

    • @saketshaurya750
      @saketshaurya750 Před 2 lety

      @@tejasjoshi1907 ty

  • @sohebshaikh3344
    @sohebshaikh3344 Před 3 lety

    Tnkq so much bahiya Keep it up

  • @tridevthakur5397
    @tridevthakur5397 Před 3 lety

    Weldone😊

  • @letsdoeverythinginoneweek9398

    FACTORIAL OF LARGE NO WALA BANAO BRO

  • @rajeshadam978
    @rajeshadam978 Před 2 lety

    👍

  • @abhishekbaital5918
    @abhishekbaital5918 Před 2 lety

    Why we are doing s.insert(a[j])

  • @user-lg4uu3ts6x
    @user-lg4uu3ts6x Před 7 měsíci

    Sir Your second solution is not running for duplicate element

  • @SakshiSharma-zv9gd
    @SakshiSharma-zv9gd Před 3 lety +1

    why you iterate loop from i to n-2 not from i to n in your 3rd approach??

    • @letsdoeverythinginoneweek9398
      @letsdoeverythinginoneweek9398 Před 3 lety

      BEACUSE left=i+1 ha agar i ko last tak la jayenga toh waise bhi loop break ho jayenga aur ek element bach jayega jo add nahi hoga

  • @SHASHANKRUSTAGII
    @SHASHANKRUSTAGII Před 3 lety +1

    I am getting TLE
    class Solution{
    public:
    //Function to find if there exists a triplet in the
    //array A[] which sums up to X.
    bool find3Numbers(int a[], int n, int target)
    {
    int ans=0;
    for(int i=0;i

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

      After the declaration of set no need to insert the elements remove that that loop

  • @vineetsinha1035
    @vineetsinha1035 Před 3 lety +1

    code not executing successfully

  • @ayanroy4150
    @ayanroy4150 Před 2 lety

    share the code

  • @suyashsharmaable
    @suyashsharmaable Před 3 lety +1

    nhi hora bhai same solution copy mara tb bhi bad memory error throw krra.

    • @suyashsharmaable
      @suyashsharmaable Před 3 lety

      ho gaya submit bhai....website pe hi kuch error tha shayad..thodi der baad submit kara toh ho gaya.. this was too strange tho.

  • @mohammedwaseem8599
    @mohammedwaseem8599 Před 3 lety +1

    If you sort then how can Tc will be O(n^2)??

    • @tusharbhart4105
      @tusharbhart4105 Před 3 lety +1

      There is a while loop inside a for loop(nested) so tc will be O(n^2).

    • @sankeerthsirikonda3565
      @sankeerthsirikonda3565 Před 2 lety

      ​@@tusharbhart4105 yeah, but sorting is done outside of the loop where TC is O(nlogn) right, how is it connected with the while loop?

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

      @@sankeerthsirikonda3565 total time complexity will be O(n logn) + O(n^2).
      Logn for tge sorting and n^2 for nested loops. But the overall complexity will be O(n^2), as we consider the biggest polynomial.

  • @PIYUSH-lz1zq
    @PIYUSH-lz1zq Před 2 lety +2

    why n-2 ??

    • @sandipsamanta5073
      @sandipsamanta5073 Před 2 lety

      Since last Pointer is n-1,

    • @ljojo
      @ljojo Před rokem

      ​@@sandipsamanta5073 thanks you for clearing my doubt dude😊

  • @darshikarathi44
    @darshikarathi44 Před 2 lety

    such a worst explanation of the code.