import java.util.Stack; import java.util.List; import java.util.ArrayList; import java.util.*;
public class Solution {
Stack<Integer> stack = new Stack<Integer>();
public void push(int node) { stack.push(node); } public void pop() { stack.pop(); } public int top() { int top = stack.pop(); stack.push(top); return top; } public int min() { List<Integer> list= new ArrayList<Integer>(); while(!stack.isEmpty()){ list.add(stack.pop()); } for(int i=list.size()-1; i>=0; i--){ stack.push(list.get(i)); } list.sort(new Comparator<Integer>(){ public int compare(Integer A, Integer B){ return A-B; }
}); return list.get(0);
} }
标签:java,函数,包含,min,int,list,pop,stack,public From: https://www.cnblogs.com/northli/p/16929186.html