8.Increasing Triplet Subsequence
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.
Return true if there exists i, j, k such that arr[i] < arr[j] < arr[k] given 0 ≤ i < j < k ≤ n-1 else return false.
Solution:
Approach: Keep track of two elements in the array min , and max. (min<max) If any time we find an element which is greater than max(Return True)
Time Complexity: O(n), Space Complexity: O(1)
Last updated