Grokking the Coding Interview: Patterns for Coding Questions
0% completed
Solution: 132 Pattern
Problem Statement
Given an array nums, containing N integers.
A 132 pattern is three numbers taken from nums in order of position: indices i < j < k with nums[i] < nums[k] < nums[j]. Naming them x, y and z, that is x < z and z < y, with x appearing first, then y, then z. It is called a '132' pattern because if you write the three as 1, 3 and 2 by size, the order they appear in is 1, then 3, then 2.
The positions matter as much as the values. [3, 1, 4, 2] has a 132 pattern, taking 1, then 4, then 2. `[4, 3, 2, 1]
.....
.....
.....
Like the course? Get enrolled and start learning!
L
lejafilip
· 2 years ago
Harder thing is to find a monotonic_stack usage.
Show 2 replies
Reading Progress
0%