class Solution {
public:
bool
find132pattern(vector
<int
>& nums
) {
if(nums
.size()<3)
return false;
stack
<int
> sta
;
int third
= INT_MIN;
for( int i
= nums
.size()-1;i
>=0;i
--){
if(nums
[i
]<third
)return true;
while(!sta
.empty()&&sta
.top()<nums
[i
]){
third
= sta
.top();
sta
.pop();
}
sta
.push(nums
[i
]);
}
return false;
}
};
作者:hust_dhc
链接:https
://leetcode
-cn
.com
/problems
/132-pattern
/solution
/zhao
-ci
-da
-yuan
-su
-by
-saberag
/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
转载请注明原文地址: https://lol.8miu.com/read-33910.html