Skip to main content
Back to problems
Leetcode
Medium
Arrays
Greedy
Google
Increasing Triplet Subsequence

Determine whether an array contains an increasing subsequence of length 3.

Acceptance 0%
Problem Statement

Given an integer array nums, determine whether there exists a subsequence of length 3 such that the three values are strictly increasing.

A subsequence does not need to be contiguous; you may delete any number of elements without changing the order of the remaining elements.

Return true if there exists indices i < j < k with nums[i] < nums[j] < nums[k], otherwise return false.

Input Format

  • A single integer array nums.

Output Format

  • Return a boolean value indicating whether an increasing triplet subsequence exists.

Constraints

  • 1 <= nums.length
  • Elements are integers.
  • The exact official limits are unknown from the provided metadata; the intended solution should work in linear time and constant extra space.
Examples
Sample cases returned by the problem API.

Example 1

Input

nums = [1, 2, 3, 4, 5]

Output

true

Explanation

The subsequence [1, 2, 3] is strictly increasing.

Example 2

Input

nums = [5, 4, 3, 2, 1]

Output

false

Explanation

No increasing subsequence of length 3 exists.

Show 1 more example

Example 3

Input

nums = [2, 1, 5, 0, 4, 6]

Output

true

Explanation

One valid subsequence is [1, 4, 6].

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.