Problem 334: Increasing Triplet Subsequence
思路
public class Solution {
public boolean increasingTriplet(int[] nums) {
if (nums == null || nums.length < 3) {
return false;
}
int smallest = Integer.MAX_VALUE;
int smaller = Integer.MAX_VALUE;
for (Integer num : nums) {
if (num <= smallest) {
smallest = num;
} else if (num <= smaller) {
smaller = num;
} else {
return true;
}
}
return false;
}
}易错点
PreviousProblem 387: First Unique Character in a StringNextProblem 325: Maximum Size Subarray Sum Equals k
Last updated