💬 Info
Given an integer array nums
, return true
if there exists a triple of indices (i, j, k)
such that i < j < k
and nums[i] < nums[j] < nums[k]
. If no such indices exists, return false
.
풀이 시간 : 25분
class Solution {
public boolean increasingTriplet(int[] nums) {
int small = Integer.MAX_VALUE;
int big = Integer.MAX_VALUE;
for (int i = 0; i < nums.length; i++) {
int num = nums[i];
if (num <= small) {
small = num;
}
if (num > small && num <= big) {
big = num;
}
if (num > big) {
return true;
}
}
return false;
}
}