LeetCode’s 132 Pattern Explained

Image for post
Image for post
Input: [1, 2, 3, 4]Output: FalseExplanation: There is no 132 pattern in the sequence.
Input: [3, 1, 4, 2]Output: TrueExplanation: There is a 132 pattern in the sequence: [1, 4, 2].
Input: [3, 1, 4, 2]minArr: [3, 1, 1, 1]At index 0, the minimum number is the only number 3.
At index 1, the minimum number is the minimum of minArr[0] and input[1]. Which is 1.
At index 2, the minimum number is the minimum of minArr[1] and input[2]. Which is 1 again.
...
Here’s how that would look like in code.
int left = minArr[i-1];

I can code and stuff.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store