Class Solution
java.lang.Object
g0301_0400.s0334_increasing_triplet_subsequence.Solution
334 - Increasing Triplet Subsequence.<p>Medium</p>
<p>Given an integer array <code>nums</code>, return <code>true</code> <em>if there exists a triple of indices</em> <code>(i, j, k)</code> <em>such that</em> <code>i < j < k</code> <em>and</em> <code>nums[i] < nums[j] < nums[k]</code>. If no such indices exists, return <code>false</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [1,2,3,4,5]</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> Any triplet where i < j < k is valid.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [5,4,3,2,1]</p>
<p><strong>Output:</strong> false</p>
<p><strong>Explanation:</strong> No triplet exists.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> nums = [2,1,5,0,4,6]</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> The triplet (3, 4, 5) is valid because nums[3] == 0 < nums[4] == 4 < nums[5] == 6.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 5 * 10<sup>5</sup></code></li>
<li><code>-2<sup>31</sup> <= nums[i] <= 2<sup>31</sup> - 1</code></li>
</ul>
<p><strong>Follow up:</strong> Could you implement a solution that runs in <code>O(n)</code> time complexity and <code>O(1)</code> space complexity?</p>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
increasingTriplet
public boolean increasingTriplet(int[] nums)
-