132 Pattern Detection Problem
132 Pattern Detection Problem — ExecCode Easy DSA Practice
Solve the 132 Pattern Detection problem on ExecCode. Free online easy DSA practice in Stack. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Your task is to compute the required answer and return trueif there is a 132 pattern innums, otherwise, returnfalse.
Examples
Input {"nums": [1, 2, 3, 4]}; Output False. Input {"nums": [3, 1, 4, 2]}; Output True. Input {"nums": [-1, 3, 2, 0]}; Output True
Constraints
n == nums.length 1 <= n <= 2 * 10^5 -10^9 <= nums[i] <= 10^9
Practice 132 Pattern Detection free on ExecCode. Browse DSA problems, topic map, and placement guides.