数据结构试验报告册,其中包括了线性表的基本操作,栈和队列的基本操作,稀疏矩阵的运算,二叉树的基本操作,图的存储和应用,查找运算实现,排序运算实现的C程序和调试结果。 Basic operation, the stack and queues are the basic operation of the matrix and operation of the basic operation of the tree, storage and application, the lookup oper
题目
225. 用队列实现栈
难度:简单
题目分析: 这题主要考察对于栈和队列性质的理解,他们的本质不同就在于元素进入和弹出的顺序,完全相反。栈是 Last In First Out (LIFO), 队列是 Fisrt In First Out (FIFO), 实现起来有点变扭。
解法:
class MyStack:
from collections import deque
def __init__(self):
Initialize you