sudopower

lc_334

LC: 334: Increasing triplet subsequence

Link to problem

Solution 1

func increasingTriplet(nums []int) bool {
    if len(nums)<3{
        return false
    }

    max:=2147483647
    i:=max
    j:=max
    k:=max
    
    for m, _:= range nums{        
            if nums[m]<=i{
                i=nums[m]
            } else if nums[m]<=j{
                j=nums[m]
            } else if nums[m]<=k{                
                return true             
            }                                
    }

    return false
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Blogs