Solution link: LeetCode discussions
Basically divide the 132 problem
into 1 problem
, and 32 problem
. Use a Monotonic stack to track the posible 2
s, a variable to track the 3
, and
finally a loop for the 1
.
Solution link: LeetCode discussions
Basically divide the 132 problem
into 1 problem
, and 32 problem
. Use a Monotonic stack to track the posible 2
s, a variable to track the 3
, and
finally a loop for the 1
.