AlgoMaster Logo

Increasing Triplet Subsequence

nums=[1, 2, 3, 4, 5]
1public boolean increasingTriplet(int[] nums) {
2    int first = Integer.MAX_VALUE;
3    int second = Integer.MAX_VALUE;
4
5    for (int num : nums) {
6        if (num <= first) {
7            first = num;
8        } else if (num <= second) {
9            second = num;
10        } else {
11            return true;
12        }
13    }
14
15    return false;
16}
0 / 8
12345