Increasing Triplet Subsequence LeetCode solution in Java

1
class Solution {
2
public boolean increasingTriplet(int[] nums) {
3
if (nums.length < 3) return false;
4

5
int x = Integer.MAX_VALUE;
6
int y = Integer.MAX_VALUE;
7

8
for (int i : nums) {
9
if (i <= x) {
10
x = i;
11
} else if (i <= y) y = i;
12
else return true;
13
}
14

15
return false;
16
}
17
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0