标签:smi util offer item ack 包含 push describe nod
1 import java.util.Stack; 2 3 public class Solution { 4 Stack<Integer> stack=new Stack<>(); 5 Stack<Integer> smin=new Stack<>(); 6 7 public void push(int node) { 8 stack.push(node); 9 if(smin.isEmpty()) 10 smin.push(node); 11 if(node<=smin.peek()) 12 smin.push(node); 13 } 14 15 public void pop() { 16 if(smin.peek()==stack.peek()) 17 smin.pop(); 18 stack.pop(); 19 } 20 21 public int top() { 22 return stack.peek(); 23 } 24 25 public int min() { 26 return smin.peek(); 27 } 28 }
标签:smi util offer item ack 包含 push describe nod
原文地址:https://www.cnblogs.com/jacob-wuhan/p/12979756.html