题目描述
blablabla
样例
blablabla
算法1
$O(n)$
Stack
时间复杂度
参考文献
Java 代码
class Solution {
public boolean find132pattern(int[] nums) {
if(nums.length < 3) return false;
Stack<Integer> stack = new Stack<>();
int second = Integer.MIN_VALUE;
stack.push(nums[nums.length-1]);
for(int i = nums.length-2;i>=0;i--){
if(nums[i]< second){
return true;
}else{
while(!stack.isEmpty() && stack.peek() < nums[i]){
second = stack.pop();
}
stack.push(nums[i]);
}
}
return false;
}
}