Skip to content

Commit 0ac6f69

Browse files
refactor 334
1 parent 6794740 commit 0ac6f69

File tree

1 file changed

+4
-19
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+4
-19
lines changed

src/main/java/com/fishercoder/solutions/_334.java

+4-19
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
11
package com.fishercoder.solutions;
22

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-
*/
203
public class _334 {
214

225
public static class Solution1 {
23-
/**Time: O(n^2)
24-
* Space: O(1)*/
6+
/**
7+
* Time: O(n^2)
8+
* Space: O(1)
9+
*/
2510
public boolean increasingTriplet(int[] nums) {
2611
if (nums == null || nums.length == 0) {
2712
return false;

0 commit comments

Comments
 (0)