Tap here to switch tabs
Problem
Submissions

Problem: Increasing Triplet Subsequence

med
30 min
Try to solve the Increasing Triplet Subsequence problem.

Statement

Given an integer array nums, determine whether there exist indices i, j, and k such that i < j < k and nums[i] < nums[j] < nums[k].

Return true if such a triplet exists; otherwise, return false.

Note: Could you implement a solution that runs in O(n) time complexity and O(1) space complexity?

Constraints:

  • 1≤1 \leq nums.length ≤5∗105\leq 5 * 10^5

  • −231≤-2^{31} \leq nums[i] ≤231−1\leq 2^{31} - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Increasing Triplet Subsequence

med
30 min
Try to solve the Increasing Triplet Subsequence problem.

Statement

Given an integer array nums, determine whether there exist indices i, j, and k such that i < j < k and nums[i] < nums[j] < nums[k].

Return true if such a triplet exists; otherwise, return false.

Note: Could you implement a solution that runs in O(n) time complexity and O(1) space complexity?

Constraints:

  • 1≤1 \leq nums.length ≤5∗105\leq 5 * 10^5

  • −231≤-2^{31} \leq nums[i] ≤231−1\leq 2^{31} - 1