Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i &lt; j &lt; k and nums[i] &lt; nums[j] &lt; nums[k]. If no such indices exists, return false.

&nbsp;
Example 1:

Input: nums = [1,2,3,4,5]
Output: true
Explanation: Any triplet where i &lt; j &lt; k is valid.


Example 2:

Input: nums = [5,4,3,2,1]
Output: false
Explanation: No triplet exists.


Example 3:

Input: nums = [2,1,5,0,4,6]
Output: true
Explanation: The triplet (3, 4, 5) is valid because nums[3] == 0 &lt; nums[4] == 4 &lt; nums[5] == 6.


&nbsp;
Constraints:


	1 &lt;= nums.length &lt;= 5 * 105
	-231 &lt;= nums[i] &lt;= 231 - 1


&nbsp;
Follow up: Could you implement a solution that runs in O(n) time complexity and O(1) space complexity?
class Solution:
    def increasingTriplet(self, nums: List[int]) -> bool:
        first = second = float('inf')
        for n in nums:
            if n <= first:
                first = n
            elif n <= second:
                second = n
            else:
                return True
        return False
class Solution {
    public boolean increasingTriplet(int[] nums) {
        if(nums.length < 3)
            return false;
        
        int x = Integer.MAX_VALUE;
        int y = Integer.MAX_VALUE;
        
        for (int i : nums){
            if(i <= x){
                x = i;
            }else if (i <= y)
                y = i;
            else 
                return true;
        }
        
        return false;
    }
}
class Solution {
public:
    bool increasingTriplet(vector<int>& nums) {
        int n = nums.size();
        int smallest = INT_MAX;
        int second_smallest = INT_MAX;
        for(int i = 0;i<n;i++)
        {
            if(nums[i] <= smallest)
            {
                smallest = nums[i];
            }
            else if(nums[i] <= second_smallest)
            {
                second_smallest = nums[i];
            }
            else
            {
                return true;
            }
        }

        return false;
    }
};
var increasingTriplet = function(nums) {
    const length = nums.length, arr = [];
    let tripletFound = false, arrLength, added = false, found = false;
    if(length < 3) return false;
    arr.push([nums[0],1]);
    for(let index = 1; index < length; index++) {
        let count = 1;
        added = false;
        found = false;
        arrLength = arr.length;
        for(let index2 = 0; index2 < arrLength; index2++) {
            if(arr[index2][0] < nums[index]) {
                added = true;
                if(count !== arr[index2][1]+1) {
                    count = arr[index2][1]+1;
                    if(JSON.stringify(arr[index2+1]) !== JSON.stringify([nums[index],count]))
                        arr.push([nums[index],count]);
                }
                if(arr[index2][1]+1 === 3) {
                    tripletFound = true;
                    break;
                }
            }
            if(arr[index2][0] === nums[index]) found = true;
        }
        if(tripletFound) break;
        if(!added && !found) {
                arr.push([nums[index],1]);
            }
    }
    return tripletFound;
};
Increasing Triplet Subsequence