1. 程式人生 > >334. Increasing Triplet Subsequence

334. Increasing Triplet Subsequence

bubuko triple true ole code sub img bool com

技術分享圖片

這題是判斷數組中是否存在三個遞增的數。代碼如下:

 1 class Solution {
 2     public boolean increasingTriplet(int[] nums) {
 3         int max = Integer.MAX_VALUE, min = Integer.MAX_VALUE;
 4         
 5         for(int num : nums){
 6             if(num <= min) min = num;
 7             else if(num <= max) max = num;
8 else return true; 9 } 10 11 return false; 12 } 13 }

END

334. Increasing Triplet Subsequence