栈
小布丁value
这个作者很懒,什么都没留下…
展开
-
剑指Offer31 栈的压入 ,弹出序列
栈的压入 ,弹出序列代码思路:class Solution { public boolean validateStackSequences(int[] pushed, int[] popped) { if(pushed==null||pushed.length<0||popped==null||popped.length<0) return false; Stack<Integer> stack=new Stack<>()原创 2021-10-22 11:38:15 · 46 阅读 · 0 评论 -
在栈中能得到栈的最小元素Min 函数,保证时间复杂度为O(1)
在这里插入代码片2.在栈中能得到栈的最小元素Min 函数,保证时间复杂度为O(1)*/class Test1 {public static Stack dataStack = new Stack<>();public static Stack assistStack = new Stack<>();//以o(1)的时间复杂度返回dataStack中的最小元素public static int getMin() {if (dataStack.isEmpty(原创 2021-04-11 10:02:17 · 78 阅读 · 0 评论