Find the triplet that sum to a given value | Q28 | Love Babbar DSA Sheet
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
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.
Thank you for the explanation, very nice. Please keep doing the great work. 🙏🙏
God bless you
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
👍👍
Please Include the logic for the Test cases in which elements in the array can repeat .
In that test case they know this logic will be going to fail
Nice bhai , well explained this problem , please explain the same way all :)
which sol is best, 2 pointer techinque or hashing for the placement purpose?
2 pointer
bcoz of space complexity
Very well explained
Sir 3rd approach ki Time Complexity O(n Log(n) ) hogi because we use sort() function. Kya mai sahi kah raha hu
n^2 logn honi chaiye shayd
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
@@tejasjoshi1907 ty
Tnkq so much bahiya Keep it up
Weldone😊
FACTORIAL OF LARGE NO WALA BANAO BRO
👍
Why we are doing s.insert(a[j])
Sir Your second solution is not running for duplicate element
why you iterate loop from i to n-2 not from i to n in your 3rd approach??
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
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
After the declaration of set no need to insert the elements remove that that loop
code not executing successfully
share the code
nhi hora bhai same solution copy mara tb bhi bad memory error throw krra.
ho gaya submit bhai....website pe hi kuch error tha shayad..thodi der baad submit kara toh ho gaya.. this was too strange tho.
If you sort then how can Tc will be O(n^2)??
There is a while loop inside a for loop(nested) so tc will be O(n^2).
@@tusharbhart4105 yeah, but sorting is done outside of the loop where TC is O(nlogn) right, how is it connected with the while loop?
@@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.
why n-2 ??
Since last Pointer is n-1,
@@sandipsamanta5073 thanks you for clearing my doubt dude😊
such a worst explanation of the code.