自己写的代码感觉就像是自己的孩子。
运行成功之后的喜悦真的太令人开心了~
贴进来记录一下~
题:力扣#456
public static boolean find132pattern(int[] nums){
int n = nums.length;
if (n < 3) {
return false;
}else{
int ak=Integer.MIN_VALUE;
Stack<Integer> st=new Stack<>();
st.push(nums[n-1]);
for (int i=n-2;i>=0;i--){
if (nums[i]<ak&&!st.empty()){
return true;
}else{
if (nums[i]<=st.peek()){
st.push(nums[i]);
}else{
while (nums[i]>st.peek()){
ak=st.pop();
if (st.empty()) break;
}
st.push(nums[i]);
}
}
}
}
return false;
}
博客作者分享了自己解决LeetCode第456题的经历,题目涉及寻找数组中的132模式。作者通过编写Java代码实现了这一功能,描述了代码逻辑并分享了运行成功的喜悦。代码中使用了栈来辅助判断,当找到符合条件的132模式时返回true,否则返回false。
311

被折叠的 条评论
为什么被折叠?



