Tap here to switch tabs
Problem
Submissions

Problem: 132 Pattern

132 Pattern asks whether an integer array contains three values in index order, with the first smallest, the second largest, and the third between them. Return true or false.

Statement

Given an integer array nums, determine whether there exist indices i, j, and k such that i < j < k and the values form a 132 pattern, meaning nums[i] < nums[k] < nums[j]. Return true if at least one such triple exists, otherwise return false.

Constraints:

  • n == nums.length

  • 1≤1 \leq n ≤2⋅105\leq 2 \cdot 10^5

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: 132 Pattern

132 Pattern asks whether an integer array contains three values in index order, with the first smallest, the second largest, and the third between them. Return true or false.

Statement

Given an integer array nums, determine whether there exist indices i, j, and k such that i < j < k and the values form a 132 pattern, meaning nums[i] < nums[k] < nums[j]. Return true if at least one such triple exists, otherwise return false.

Constraints:

  • n == nums.length

  • 1≤1 \leq n ≤2⋅105\leq 2 \cdot 10^5

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9