```
public boolean find132pattern(int[] nums) {
Stack<Range> stack = new Stack<>();
for(int num : nums) {
Range cur = new Range(num, num);
while(!stack.isEmpty() && cur.max > stack.peek().min) {
cur.min = Math.min(stack.peek().min, cur.min);
cur.max = Math.max(stack.peek().max, cur.max);
stack.pop();
}
stack.push(cur);
if(stack.peek().min < num && num < stack.peek().max)
return true;
}
return false;
}
public static class Range {
public int min;
public int max;
public Range(int mn, int mx) {
min = mn;
max = mx;
}
}
Time complexity: O(n)
Space complexity: O(n)
```