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 !
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]
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)
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
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??
@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.
[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.
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.
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.
Pre-compute left min and right max really opened my brain. Just WOW
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 !
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]
nailed it .... awesome explanation from brute force to optimal
Glad it helped!
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)
yes third approach doesn't work
Yup it also fails for 2,1,5,0,0,6
I tried it using Longest Increasing Subsequence and got TLE 😂
Haha
Ee to sala hona hi tha 😂
Great solution,
Definitely become awesome if handwriting slightly better
Amazing explanation
thanks and welcome to channel
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
Thanks and Sorry for Soun Quality - Will take care from new videos.
@@NareshGupta Nothing to sorry about! Great content, keep on that :)!
nums[i] != lm[i] and nums[i] != rm[i]
THANK YOU
That second solution is wrong.... It fails for this kinda input 2,1,5,4,0,6
Nailed it !!! Loved your explanation !! :)
Glad it helped!
Really poor explanation for the third approach. At least try to explain the intution rather than pre-compiled algorithm from leetcode.
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??
ok now got the actual solution.....thank you sir
Great.
Thank you!!
You're welcome!
Thanks that is create actually
how to come up with this line of thinking !
be a man
@@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
@@JJ-qv8co bhai ye kaisi baat keh rhe... ab koi iss cheez k liye gender kyun change krwaaye?
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
@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.
[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.
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.
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.
so the loop returning false will always happen when loop exhausted at updating first number.
your solution is wrong because your space complexity is O(N) and the required in question is O(1)
thanks man!!
Happy to help!
Thanks
Welcome
Wow😁
to the point explanation 🔥
thanks
perfect video
thanks
Best explanation Bro 🔥👍🏻
Glad you liked it
Sir this code will fails
I tried on gfg
Ex- 48,43,60,2,93
Your output true
But actual false.
Why you are thinking there is no incresing triplet subsequence in you input?
@@NareshGupta sir check on gfg
It will give wrong answer
Or check my input case
It will give wrong answer
@@sahilsaxena8374 This is not answer of my question.
48,43,60,2,93 --> [48, 60 93], [43, 60, 93] ==> clearly two increasing triplet subsequence.
@@NareshGupta
But sir value of i,j,k vo toh shi nhi h
bhai, hindi mai kosis krlo
really POOR explanation for 3rd approach
May, I know what was not clear in that so that I can take care on that part?
@@NareshGupta At last, when you were explaining how we got an increasing triplet subsequence, I mean when f became 0.
Awesome explanation
Keep watching