Given an integer array nums, return true if there are indices i < j < k with nums[i] < nums[j] < nums[k]. If no such three indices exist, return false.
Given an integer array nums, return true if there are indices i < j < k with nums[i] < nums[j] < nums[k]. If no such three indices exist, return false.
Example 1:
Input: {"nums":[1,2,3,4,5]}
Output: true
Constraints:
1≤nums.length≤5×105
−231≤nums[i]≤231−1
Follow up: can you solve it in O(n) time and O(1) extra space?
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[1,2,3,4,5]}
first and second start at infinity. first is the smallest value seen; second is the smallest value that has something smaller before it.