Q1: 使用两者栈实现一个队列,完成队列的push和pop操作,队列中的元素是int类型
思路:
压入元素直接压入statck1,删除元素先查看statck2是否为空,非空就弹出;空则将stack1中元素取出,置于stack2中。
1 |
public class { |
Q1: 使用两者栈实现一个队列,完成队列的push和pop操作,队列中的元素是int类型
思路:
压入元素直接压入statck1,删除元素先查看statck2是否为空,非空就弹出;空则将stack1中元素取出,置于stack2中。
1 |
public class { |
近期评论