MEDIUMasked at 2 companies

132 Pattern

A medium-tier problem at 34% community acceptance, tagged with Array, Binary Search, Stack. Reported in interviews at Intuit and 1 others.

Founder's read

You're looking at a medium-difficulty array problem that's appeared in Intuit and IBM interviews. The 132 Pattern asks you to find three indices i, j, k where i < j < k and nums[i] < nums[k] < nums[j]. It's not about sorting or greedy logic. The trap is thinking you can brute-force all triplets, which tanks on large inputs. The real solution hinges on a monotonic stack and knowing when to use a Balanced BST pattern. About 34% of candidates nail this cold. If you haven't drilled monotonic stacks hard, StealthCoder surfaces the working solution in seconds during your live OA, invisible to the proctor.

Companies asking
2
Difficulty
MEDIUM
Acceptance
34%

Companies that ask "132 Pattern"

If this hits your live OA

132 Pattern is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.

Get StealthCoder
What this means

The 132 Pattern feels like a search problem at first, but the key insight is order and range. You're not sorting. You're scanning right-to-left and maintaining the largest valid 'third element' (nums[k]) you've seen so far, while using a monotonic stack to track potential 'middle elements' (nums[j]). For each new number from the left, you check if it's smaller than that stored maximum. The monotonic stack handles the 'j < k' constraint and helps you prune candidates efficiently. Candidates often try two-pointer or greedy approaches first and hit O(n^2) or O(n log n) with poor constants. The stack-based solution is O(n) with a small multiplier. If the pattern doesn't click in real time, StealthCoder is the backstop that gets you past the block and into submission.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

132 Pattern recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.

132 Pattern interview FAQ

Is 132 Pattern actually asked at big companies, or is it too obscure?+

It's appeared at Intuit and IBM explicitly. It's a medium-difficulty problem with moderate acceptance, so it shows up when interviewers want to test monotonic stack and ordered-set thinking. Not a guarantee, but frequent enough that it's worth knowing the pattern cold.

What's the trick that separates AC from TLE?+

Brute-force triplet checking is O(n^3) or O(n^2). The intended solution uses a monotonic decreasing stack plus tracking the maximum valid middle value. This lets you find the pattern in a single pass without nested loops.

How does monotonic stack actually help here?+

The stack maintains candidates for the middle element (nums[j]) in decreasing order. When a new number breaks that order, you know it can be a valid first element (nums[i]) for the largest valid third element you've stored. This constraint ordering is what makes the solution linear.

Do I need to memorize the stack logic or can I derive it?+

Deriving it from scratch in 20 minutes is risky unless you've solved similar monotonic stack problems already. The relationship between the three elements isn't intuitive at first glance. Drilling the pattern beforehand is safer than hoping you can invent it live.

Should I use an Ordered Set or a Stack?+

Both work, but stack is more efficient and the intended approach. An ordered set (TreeMap, TreeSet) can also solve it, but stack better captures the constraint structure and runs faster in practice. Know both, prefer stack for interviews.

Want the actual problem statement? View "132 Pattern" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.