Precise Java Solution


  • 0
    L

    public boolean find132pattern(int[] nums) {

    if(nums == null || nums.length < 3)
    	return false;
    	
    for (int i = 0; i < nums.length-1; i++) {
    	int max = nums[i];
    	for (int j = i+1; j < nums.length; j++) {
    		if(nums[j] > max)
    			max = nums[j];
    		
    		if(nums[j] < max && nums[j] > nums[i] && max != nums[i])
    			return true;				
    	}
    }
    	
    return false;
    

    }


Log in to reply
 

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