shlogg · Early preview
Rakesh Reddy Peddamallu @rakesh678219

Software Engineering Web Development Increasing Triplet Solution

Three approaches to solve increasingTriplet problem: Brute Force (O(n^3)), Two Pointer, and Greedy. Greedy approach is most efficient with time complexity O(n).

Tried this but not a right solution

/**
 * @param {number[]} nums
 * @return {boolean}
 */
var increasingTriplet = function(nums) {
  for(let i = 0 ; i<nums.length-2;i++){
        let a = i;
        let b = i+1;
        let c = i+2
        if(nums[i]<nums[i+1] && nums[i+1]<nums[i+2]){
            return true
        }
    }
    return false
};

    
    

    
    




Some cases will fail with the above solution because we should not be finding consecutive triplets
Brute Force Approach
It's easy to use Brute Force way to solve this problem, but the time complexity is O(n3), it will TLE, so w...