We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 65f1b84 commit 11b2ce3Copy full SHA for 11b2ce3
Arrays/334_Increasing_Triplet_Subsequence.java
@@ -1,17 +1,13 @@
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;
+ int smallest = Integer.MAX_VALUE, secondSmallest = 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 {
+ if (num <= smallest) {
+ smallest = num;
+ } else if (num < secondSmallest) {
+ secondSmallest = num;
+ } else if (num > secondSmallest) {
15
return true;
16
}
17
0 commit comments