Skip to content

Commit a4d51c5

Browse files
committed
Time: 86 ms (68.73%), Space: 38.3 MB (29.21%) - LeetHub
1 parent dbed71a commit a4d51c5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

456-132-pattern/456-132-pattern.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
public:
3+
bool find132pattern(vector<int>& nums) {
4+
5+
stack <int> stack;
6+
int second = -2147483648;
7+
for (int i = nums.size() - 1; i >= 0; i--) {
8+
if (nums [i] < second)
9+
return true;
10+
while (stack.size() >0 && nums [i] > stack.top()){
11+
second = stack.top ();
12+
stack.pop();
13+
}
14+
15+
stack.push (nums [i]);
16+
}
17+
return false;
18+
19+
}
20+
};

0 commit comments

Comments
 (0)