Skip to content

Commit 9b4baad

Browse files
Sean PrashadSean Prashad
authored andcommitted
Add 334_Increasing_Triplet_Subsequence.java
1 parent 0584aab commit 9b4baad

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public boolean increasingTriplet(int[] nums) {
3+
if (nums == null || nums.length < 3) {
4+
return false;
5+
}
6+
7+
int small = Integer.MAX_VALUE, big = Integer.MAX_VALUE;
8+
9+
for (int num : nums) {
10+
if (num <= small) {
11+
small = num;
12+
} else if (num <= big) {
13+
big = num;
14+
} else {
15+
return true;
16+
}
17+
}
18+
19+
return false;
20+
}
21+
}

0 commit comments

Comments
 (0)