Skip to content

Commit 5f9b4f7

Browse files
committed
Increasing Triplet Sequence
1 parent 3d84aee commit 5f9b4f7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

LeetCode/ProgrammingInGo/increasingtriplets/increasingtripletsequence.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
/*
2+
Leetcode 75
3+
4+
Given an integer array nums, return true if there exists a triple
5+
of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k]. If no
6+
such indices exists, return false.
7+
8+
Example 1:
9+
10+
Input: nums = [1,2,3,4,5]
11+
Output: true
12+
Explanation: Any triplet where i < j < k is valid.
13+
Example 2:
14+
15+
Input: nums = [5,4,3,2,1]
16+
Output: false
17+
Explanation: No triplet exists.
18+
Example 3:
19+
20+
Input: nums = [2,1,5,0,4,6]
21+
Output: true
22+
Explanation: The triplet (3, 4, 5) is valid because
23+
nums[3] == 0 < nums[4] == 4 < nums[5] == 6.
24+
25+
Constraints:
26+
27+
1 <= nums.length <= 5 * 105
28+
-231 <= nums[i] <= 231 - 1
29+
30+
31+
Follow up: Could you implement a solution that runs in O(n) time complexity
32+
and O(1) space complexity?
33+
*/
34+
135
package increasingtriplets
236

337
import "math"

0 commit comments

Comments
 (0)