Problem
You get an integer array nums. Return true if there are three indexes i, j and k with i < j < k and nums[i] < nums[j] < nums[k]. Return false otherwise.
The three items do not have to be next to each other. They form a subsequence, which is a group of items that keeps the order of the array.
Example 1
- Input:
- nums = [6,2,9,3,8]
- Output:
- true
- Explanation:
- The items at indexes 1, 3 and 4 are 2, 3 and 8. These values increase.
Example 2
- Input:
- nums = [9,7,7,4,1]
- Output:
- false
- Explanation:
- The values never increase from left to right.
Example 3
- Input:
- nums = [5,1,6,0,2,3]
- Output:
- true
- Explanation:
- The items 0, 2 and 3 at indexes 3, 4 and 5 increase. The items 1, 2 and 3 also increase.
Constraints
- 1 <= nums.length <= 5 * 10^5
- -2^31 <= nums[i] <= 2^31 - 1
Follow-up
Find a solution that runs in O(n) time and uses O(1) extra space.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Longest Continuous Increasing Subsequence
Coding
- Longest Increasing Subsequence
Coding · Array · Binary Search · Dynamic Programming
- Longest Increasing Subsequence II
Coding
- Maximum Increasing Triplet Value
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 334. Increasing Triplet Subsequence
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source