C# solution


  • 0
    A
    public bool IncreasingTriplet(int[] nums) {
            if(nums.Length < 3)
            {
                return false;
            }
            
            int min = Int32.MaxValue;
            int highier = Int32.MaxValue;
            
            for(int i = 0; i < nums.Length; ++i)
            {
                if(nums[i] < min)
                {
                    min = nums[i];
                }
                else if(highier > nums[i] && nums[i] > min)
                {
                    highier = nums[i];
                }
                else if(nums[i] > highier)
                {
                    return true;
                }
            }
            
            return false;
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.