The problem. Given an integer array nums, return true if there are three indexes i < j < k with nums[i] < nums[j] < nums[k] — three values that increase from left to right — and false otherwise. They don't need to be next to each other. The follow-up asks for O(n) time and O(1) space.
Input: nums = [1, 2, 3, 4, 5]
Output: true e.g. 1 < 2 < 3
Input: nums = [5, 4, 3, 2, 1]
Output: false the values only fall
Input: nums = [2, 1, 5, 0, 4, 6]
Output: true e.g. 1 < 4 < 6, or 0 < 4 < 6Free account
Sign up to read the rest of this lesson: 5 more sections, 3 drawings, a dry-run simulator and code in JavaScript, Python, Java and C++.
Still to come