My c++ solution


  • -2
    D
    bool increasingTriplet(vector<int>& nums) {
        if(nums.size()<3) return false;
        int two[2]={INT_MAX, INT_MAX};
        int one[1]={INT_MAX};
        for(int i=0; i<nums.size();i++)
        {
            if(nums[i] > two[1]) return true;
            if(nums[i] > two[0]) two[1] = nums[i];
            else if(nums[i] < two[0] && nums[i] > one[0])
            {
                two[0] = one[0];
                two[1] = nums[i];
            }
            else if(nums[i] < one[0])
                one[0] = nums[i];
        }
        return false;
    }

Log in to reply
 

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