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)
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??
[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.
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
@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.