public class Solution {
public boolean increasingTriplet(int[] nums) {
// 设置两个变量,用来记录最小的和中间的值
int small = Integer.MAX_VALUE;
int middle = Integer.MAX_VALUE;
for (int num : nums) {
if (num <= small) {
small = num;
} else if (num <= middle) {
middle = num;
}
// 如果数比这两个都大,返回true
else {
return true;
}
}
return false;
}
}