8ms c++ solution


  • 0
    C
    class Solution {
    public:
    	bool increasingTriplet(vector<int>& nums) {
    		vector<int> lastNums(3,INT_MAX);
    		for (auto num : nums){
    			int index = 2;
    			for (; index > -1; index--)
    				if (num > lastNums[index])
    					break;
    			if (index >= 1)
    				return true;
    			else
    				lastNums[index + 1] = num;
    		}
    		return false;
    
    	}
    };
    

Log in to reply
 

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