334. Increasing Triplet Subsequence - Day 11/31 Leetcode October Challenge
Ғылым және технология
Larry solves and analyzes this Leetcode problem as both an interviewer and an interviewee. This is a live recording of a real engineer solving a problem live - no cuts or edits!
Problem: leetcode.com/problems/increas...
Twitch: / larryny
Discord: / discord
Instagram: / larrysomewhere
#leetcode #coding #programming
Пікірлер: 9
Were you able to get increasing?
@narolavarshil6067
Жыл бұрын
I did with minpref and maxsuf with n time and n space.. But your explanation was amazing doing question with maximum length of increasing subsequence way which was asked in recent contest
Such a tricky solution. First I thought it’s wrong because we change the first number and leave the second one, so the index order might be wrong. But then I tried couple of test cases in mind and understood that since we need to return just boolean number, that solution works fine. Thanks!
Agh! Just had to keep track of the smallest and second smallest numbers.. This helped a lot - thanks Larry! 😄
please don't ever stop recording these daily 🙏❤
This was really helpful, thank you so much!
This was so helpful!! Thank you
what if it is Increasing 4 Subsequence, how would the algorithm change?
N=len(nums) arr=[nums[0]] for i in range(1,N): x=nums[i] if x>arr[-1]: arr.append(x) else: index=bisect.bisect_left(arr,x) arr[index]=x if len(arr)>2: return True return False #above code using longest increasing subsequence problem with O(N) time and O(1) space