Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool find132pattern(vector<int>& nums) {
- bool found = false;
- stack<int> stk;
- int sz = nums.size(), num2;
- num2 = INT_MIN;
- for(int i=sz-1; i>=0; i--){
- if(nums[i] < num2) found = true;
- while(!stk.empty() && stk.top() < nums[i]){
- num2 = max(num2, stk.top());
- stk.pop();
- }
- stk.push(nums[i]);
- }
- return found;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment