Skip to content

Commit 0902810

Browse files
authored
Create Solution.java
1 parent 6e1c59e commit 0902810

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public boolean find132pattern(int[] nums) {
3+
int ak = Integer.MIN_VALUE;
4+
Deque<Integer> stack = new ArrayDeque<>();
5+
for (int i = nums.length - 1; i >= 0; --i) {
6+
if (nums[i] < ak) {
7+
return true;
8+
}
9+
while (!stack.isEmpty() && nums[i] > stack.peek()) {
10+
ak = stack.pop();
11+
}
12+
stack.push(nums[i]);
13+
}
14+
return false;
15+
}
16+
}

0 commit comments

Comments
 (0)