Тёмный

Increasing Triplet Subsequence | leetcode 334 | followup On Time O1 Space 

Naresh Gupta
Подписаться 10 тыс.
Просмотров 21 тыс.
50% 1

Опубликовано:

 

16 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 63   
@codelite700
@codelite700 Год назад
Pre-compute left min and right max really opened my brain. Just WOW
@Account-fi1cu
@Account-fi1cu 2 года назад
I'm reading the comments and most people who complain probably didn't listen till the end of the video or paid any attention. You covered all important steps to tackle this problem, giving us 3 approaches from least efficient all the way to the optimized, preferred solution, THANK YOU !
@anirudhatalmale5575
@anirudhatalmale5575 3 года назад
nailed it .... awesome explanation from brute force to optimal
@NareshGupta
@NareshGupta 3 года назад
Glad it helped!
@akshaychavan5511
@akshaychavan5511 7 месяцев назад
The idea is brilliant, but kind of slow. Here are two approaches - approach 1 - def increasingTriplet(self, nums: List[int]) -> bool: num1 = num2 = float('inf') for n in nums: if n leftMin[i] and nums[i]
@NikhilKumar-od7qh
@NikhilKumar-od7qh 2 года назад
I think the test case [5,1,4,2,0,3] fails with the third approach because it gives true by considering triplet (0,2,3) while the actual triplet needed to be considered is (1,2,3)
@kuntasunny8688
@kuntasunny8688 2 года назад
yes third approach doesn't work
@kushagarsharma4783
@kushagarsharma4783 5 месяцев назад
Yup it also fails for 2,1,5,0,0,6
@prasadm3614
@prasadm3614 11 месяцев назад
That second solution is wrong.... It fails for this kinda input 2,1,5,4,0,6
@KundanKumar-im1gs
@KundanKumar-im1gs 3 года назад
but when i am trying to dry run the example that you have given....the value of first came out to be 2, second 6 and third 7, which will return true...but the order in question is not according to ans....how??
@KundanKumar-im1gs
@KundanKumar-im1gs 3 года назад
ok now got the actual solution.....thank you sir
@NareshGupta
@NareshGupta 3 года назад
Great.
@tanvishinde805
@tanvishinde805 3 года назад
how to come up with this line of thinking !
@JJ-qv8co
@JJ-qv8co 3 года назад
be a man
@bishwashkumarsah171
@bishwashkumarsah171 2 года назад
@@JJ-qv8co but she is a women she cannot change her gender now....u should have just said practice more and u will get the approach lol
@amaan6017
@amaan6017 Год назад
​@@JJ-qv8co bhai ye kaisi baat keh rhe... ab koi iss cheez k liye gender kyun change krwaaye?
@adarshnegi4785
@adarshnegi4785 Год назад
[20,100,10,12,5,13] for test case. value of f finally becomes 5 , value of s beomes 12 , how it still returning true. i am stuck with this, even a little help will be appreiciated.
@swayambhunathan
@swayambhunathan 9 месяцев назад
because in next iteration both the if conditions for updating first and second values are skipped as 13 is not lesser than both values. but from previous updating of values we know we have two values updated in sequence and third one which is 13 is definitely bigger than last two updated numbers as both the numbers didn't get updated. so it goes to the else part and return true. I hope it makes sense.
@swayambhunathan
@swayambhunathan 9 месяцев назад
it doesn't matter how many times both the numbers are getting updated. what matters is whenever both the numbers are getting updated it is giving us a subsequence. so in any further iterations if both the numbers are not getting updated it automatically means next number is bigger.
@swayambhunathan
@swayambhunathan 9 месяцев назад
so the loop returning false will always happen when loop exhausted at updating first number.
@aayushpagare9366
@aayushpagare9366 3 года назад
I tried it using Longest Increasing Subsequence and got TLE 😂
@NareshGupta
@NareshGupta 3 года назад
Haha
@saranshgupta9119
@saranshgupta9119 3 года назад
Ee to sala hona hi tha 😂
@bhagavanprasad
@bhagavanprasad Год назад
Great solution, Definitely become awesome if handwriting slightly better
@arpitsatnalika
@arpitsatnalika 3 года назад
Amazing explanation
@NareshGupta
@NareshGupta 3 года назад
thanks and welcome to channel
@aneesbazmi1612
@aneesbazmi1612 Год назад
nums[i] != lm[i] and nums[i] != rm[i]
@DonTaldo
@DonTaldo 3 года назад
Thanks for sharing! The content is pretty good but the sound isn't the greatest, I'd consider doing some investment over there since the content is very valuable
@NareshGupta
@NareshGupta 3 года назад
Thanks and Sorry for Soun Quality - Will take care from new videos.
@DonTaldo
@DonTaldo 3 года назад
@@NareshGupta Nothing to sorry about! Great content, keep on that :)!
@guptapaaras
@guptapaaras 10 месяцев назад
Really poor explanation for the third approach. At least try to explain the intution rather than pre-compiled algorithm from leetcode.
@sharuk3545
@sharuk3545 2 года назад
this is not O(1) SC bcz you take 2 extra arrays and its size depends on n there is no chance that we can say its O(1) SC
@NareshGupta
@NareshGupta 2 года назад
@Sharuk I think you missed second half of the video. In video two solution is covered once with with array (definitely O(n) space) and without array with constant variables that is O(1) space.
@adityan5302
@adityan5302 2 года назад
Nailed it !!! Loved your explanation !! :)
@NareshGupta
@NareshGupta 2 года назад
Glad it helped!
@Meenereem
@Meenereem 11 месяцев назад
THANK YOU
@MennaTullahabdelrahman
@MennaTullahabdelrahman Год назад
Thanks that is create actually
@shubhamchavan1387
@shubhamchavan1387 3 года назад
Thank you!!
@NareshGupta
@NareshGupta 3 года назад
You're welcome!
@Ammar23217
@Ammar23217 Год назад
your solution is wrong because your space complexity is O(N) and the required in question is O(1)
@payalsagar1808
@payalsagar1808 3 года назад
Wow😁
@sahilsaxena8374
@sahilsaxena8374 3 года назад
Sir this code will fails I tried on gfg Ex- 48,43,60,2,93 Your output true But actual false.
@NareshGupta
@NareshGupta 3 года назад
Why you are thinking there is no incresing triplet subsequence in you input?
@sahilsaxena8374
@sahilsaxena8374 3 года назад
@@NareshGupta sir check on gfg It will give wrong answer
@sahilsaxena8374
@sahilsaxena8374 3 года назад
Or check my input case It will give wrong answer
@NareshGupta
@NareshGupta 3 года назад
@@sahilsaxena8374 This is not answer of my question. 48,43,60,2,93 --> [48, 60 93], [43, 60, 93] ==> clearly two increasing triplet subsequence.
@sahilsaxena8374
@sahilsaxena8374 3 года назад
@@NareshGupta But sir value of i,j,k vo toh shi nhi h
@VivekGupta-mn7vy
@VivekGupta-mn7vy 2 года назад
thanks man!!
@NareshGupta
@NareshGupta 2 года назад
Happy to help!
@AhmedSoliman-dk6pc
@AhmedSoliman-dk6pc 7 месяцев назад
Thanks
@NareshGupta
@NareshGupta 7 месяцев назад
Welcome
@prateekbansal2014
@prateekbansal2014 2 года назад
to the point explanation 🔥
@NareshGupta
@NareshGupta 2 года назад
thanks
@rohitanjane1668
@rohitanjane1668 Год назад
Best explanation Bro 🔥👍🏻
@NareshGupta
@NareshGupta Год назад
Glad you liked it
@arpitvijay9382
@arpitvijay9382 Год назад
perfect video
@NareshGupta
@NareshGupta Год назад
thanks
@gunjanagrawal6032
@gunjanagrawal6032 3 года назад
really POOR explanation for 3rd approach
@NareshGupta
@NareshGupta 3 года назад
May, I know what was not clear in that so that I can take care on that part?
@ankitdas6009
@ankitdas6009 3 года назад
@@NareshGupta At last, when you were explaining how we got an increasing triplet subsequence, I mean when f became 0.
@khushable
@khushable 3 года назад
Awesome explanation
@NareshGupta
@NareshGupta 3 года назад
Keep watching
Далее
Increasing Triplet Subsequence | Leetcode #334
18:57
Просмотров 4,3 тыс.
Слушали бы такое на повторе?
01:00
Longest Consecutive Sequence | Leetcode(Hard) | GooGLe
13:47
If Your Tech Job is Comfortable, You're in Danger
20:57