Leetcode 334 Increasing Triplet Subsequence - Python Solution
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array. Approach - We take two variables a and b . We initialize them to the biggest number in the array and then we iterate over the list and if a value is found less than the current value of a and b we change them. If a value greater than both of them is found then we return True which means we have found increasing subsequence. Here don’t get confused with the fact that the subsequence can be non - contiguous .
|
|