456. 132模式
不会做
class Solution {
public boolean find132pattern(int[] nums) {
int len = nums.length;
if(len<3) {
return false;
}
int[] leftLow = new int[len];
leftLow[0] = nums[0];
int min = nums[0];
for(int i = 0 ; i < len;i++) {
if(nums[i]<min) {
min = nums[i];
}
leftLow[i] = min;
}
Stack<Integer> stack = new Stack();
stack.push(nums[len-1]);
for(int j = len-2; j>=0;j--) {
if(nums[j]==leftLow[j]) continue;
while(!stack.isEmpty() && stack.peek() <= leftLow[j])
stack.pop();
if(!stack.isEmpty() && nums[j]>stack.peek()) {
return true;
}
stack.push(nums[j]);
}
return false;
}
}