File tree 1 file changed +4
-19
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +4
-19
lines changed Original file line number Diff line number Diff line change 1
1
package com .fishercoder .solutions ;
2
2
3
- /**
4
- * 334. Increasing Triplet Subsequence
5
- *
6
- * Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.
7
- *
8
- * Formally the function should:
9
- * Return true if there exists i, j, k
10
- * such that arr[i] < arr[j] < arr[k] given 0 ≤ i < j < k ≤ n-1 else return false.
11
- * Your algorithm should run in O(n) time complexity and O(1) space complexity.
12
-
13
- Examples:
14
- Given [1, 2, 3, 4, 5],
15
- return true.
16
-
17
- Given [5, 4, 3, 2, 1],
18
- return false.
19
- */
20
3
public class _334 {
21
4
22
5
public static class Solution1 {
23
- /**Time: O(n^2)
24
- * Space: O(1)*/
6
+ /**
7
+ * Time: O(n^2)
8
+ * Space: O(1)
9
+ */
25
10
public boolean increasingTriplet (int [] nums ) {
26
11
if (nums == null || nums .length == 0 ) {
27
12
return false ;
You can’t perform that action at this time.
0 commit comments