Skip to content

Commit 11b2ce3

Browse files
Sean PrashadSean Prashad
authored andcommitted
Update 334_Increasing_Triplet_Subsequence.java
1 parent 65f1b84 commit 11b2ce3

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

Arrays/334_Increasing_Triplet_Subsequence.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
class Solution {
22
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;
3+
int smallest = Integer.MAX_VALUE, secondSmallest = Integer.MAX_VALUE;
84

95
for (int num : nums) {
10-
if (num <= small) {
11-
small = num;
12-
} else if (num <= big) {
13-
big = num;
14-
} else {
6+
if (num <= smallest) {
7+
smallest = num;
8+
} else if (num < secondSmallest) {
9+
secondSmallest = num;
10+
} else if (num > secondSmallest) {
1511
return true;
1612
}
1713
}

0 commit comments

Comments
 (0)