Increasing Triplet Subsequence
Problem Statement
You are given a list of numbers nums.
Decide if there are three positions i < j < k, in that order, where nums[i] < nums[j] < nums[k]. The three numbers do not need to be next to each other.
Follow-up: can you do it in one pass with only a few variables?
An integer array nums.
true if such a triple exists, otherwise false.
Any three positions in order work, for example 1, 2, 3.
The numbers only go down, so no triple exists.
The numbers 1, 4, 6 are at positions 1, 4, 5 and increase. The numbers 0, 4, 6 at positions 3, 4, 5 also work.
- • 1 ≤ nums.length ≤ 5 · 10^5
- • −2^31 ≤ nums[i] ≤ 2^31 − 1
Pattern Recognition Clues
Recognising these key signals in the problem description immediately identifies the pattern:
Approach Complexity Ladder
Check every triple of positions i < j < k
For each middle item, compare it with the smallest value on its left and the largest on its right
Track the smallest value so far, and the smallest middle candidate; a bigger value finishes a triple
Use three nested loops to pick positions i < j < k, and test nums[i] < nums[j] < nums[k]. If any triple passes, the answer is true.
Recognition rule for this sub-pattern:
Unlock Complete Visual Walkthrough & Optimal C++
The interactive animated dry-run player, optimized C++ implementation, state invariant derivations, and edge-case breakdown for this question are part of Brute2Best Pro. The anchor question of every sub-pattern is completely free.
First anchor question per pattern, Part 1 LLD & Module 1 C++ basics are 100% Free forever.
How this concept connects to System Design & C++ Systems
Top engineering interviews test whether you understand how algorithms like DP — Longest Increasing Subsequence translate into production architectures and low-level memory mechanics.
Foundations: Object-Oriented Principles in C++23
Class invariants, pure virtual interfaces, and RAII smart pointers.
Food Delivery System (Zomato Architecture)
Real-world machine coding application of algorithms and design patterns.
Pointers vs References Deep Dive
Pointer arithmetic and memory layout under the hood.
Virtual Method Table (vtable) & Memory Layout
Polymorphism, vptr overhead, and multiple inheritance in memory.