标签:一个 时间 java 元素 turn col describe 时间复杂度 class
import java.util.Stack; public class Solution { Stack<Integer> stack1 = new Stack<Integer>(); Stack<Integer> stack2 = new Stack<Integer>(); public void push(int node) { stack1.push(node); if(stack2.empty()) stack2.push(node); if(node<stack2.peek()) stack2.push(node); } public void pop() { if(stack1.peek()==stack2.peek()){ stack1.pop(); stack2.pop(); } else{ stack1.pop(); } } public int top() { return stack1.peek(); } public int min() { return stack2.peek(); } }
标签:一个 时间 java 元素 turn col describe 时间复杂度 class
原文地址:https://www.cnblogs.com/loyolh/p/12343102.html