82. Increasing Triplet Subsequence

MediumArrayArray

Given integer array nums, return true if there exist indices i<j<k with nums[i]<nums[j]<nums[k], else false. Must run in O(n) time O(1) space.

Input: Integer array nums.

Output: true or false.

Examples

Example 1
Input: [1,2,3,4,5]
Output: true
Explanation: 1<2<3.
Example 2
Input: [5,4,3,2,1]
Output: false
Explanation: Strictly decreasing.
Example 3
Input: [2,1,5,0,4,6]
Output: true
Explanation: 0<4<6.

Constraints

Asked by

MetaBloombergMicrosoftAmazonGoogle
Solve this problem in the editor →