My 2ms way to slove this three incresing number problem


  • 0
    G
    public boolean increasingTriplet(int[] nums) { //triplet problem incress three pair
    	
    	int min2num=2147483647;
    	int minnum=2147483647;
    	for(int i=0;i<nums.length-1;i++)
    	{
    		minnum=Math.min(minnum, nums[i]);
    		if((nums[i]>min2num)||(nums[i+1]>min2num))
    			return true;
    		if(nums[i]<nums[i+1])
    		{
    			min2num=Math.min(min2num, nums[i+1]);
    			if(nums[i]>minnum)
    				return true;
    		}	
    	}
    	return false;
        }

Log in to reply
 

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