Detect a Strictly Increasing Three-Index Pattern

Quick Overview

Detect a Strictly Increasing Three-Index Pattern. Decide whether three positions appear in increasing index order and their three values are strictly increasing. Return only whether such a triple exists.

Detect a Strictly Increasing Three-Index Pattern

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Other

### Problem Return whether there exist indices i<j<k with nums[i]<nums[j]<nums[k]. Only existence is returned, not the triple itself. ```cpp bool increasingTriplet(vector<int>& nums); ``` ### Examples ```text nums = [5,1,4,2,3] -> true nums = [2,2,2] -> false ``` ### Constraints - Length is 1 through 500000. - Entries span the signed 32-bit domain. ### Optional follow-up Can you achieve O(n) time and O(1) extra space?

Overview: Detect a Strictly Increasing Three-Index Pattern. Decide whether three positions appear in increasing index order and their three values are strictly increasing. Return only whether such a triple exists.

Amazon logo
Amazon
Jul 16, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0

Problem

Return whether there exist indices i<j<k with nums[i]<nums[j]<nums[k]. Only existence is returned, not the triple itself.

bool increasingTriplet(vector<int>& nums);

Examples

nums = [5,1,4,2,3] -> true
nums = [2,2,2] -> false

Constraints

  • Length is 1 through 500000.
  • Entries span the signed 32-bit domain.

Optional follow-up

Can you achieve O(n) time and O(1) extra space?