【题目】不使用递归,对二叉树进行先序、中序和后序遍历【思路】利用栈先序:1. 输出当前结点2. 把右孩子放到栈中3. 当前指针指向左孩子4. 重复1-3,直到叶子结点5. 如果栈不空,则从栈里POP出一个结点,赋值给当前节点6. 重复1-5中序:1. 如果当前节点不为空,把当前节点PUSH2. 当前...
分类:
其他好文 时间:
2014-11-17 15:30:06
阅读次数:
141
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get ...
分类:
其他好文 时间:
2014-11-16 13:30:08
阅读次数:
174
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov...
分类:
其他好文 时间:
2014-11-15 23:12:56
阅读次数:
193
题目描述【问题背景】栈是计算机中经典的数据结构,简单的说,栈就是限制在一端进行插入删除操作的线性表。栈有两种最重要的操作,即pop(从栈顶弹出一个元素)和push(将一个元素进栈)。栈的重要性不言自明,任何一门数据结构的课程都会介绍栈。宁宁同学在复习栈的基本概念时,想到了一个书上没有讲过的问题,而他...
分类:
其他好文 时间:
2014-11-15 18:42:03
阅读次数:
215
Leetcode更新到155题了,这个easy的题acceptance却不高,我好奇的点开了它。Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(...
分类:
编程语言 时间:
2014-11-14 19:24:03
阅读次数:
240
1、push方法(Array)将新元素追加到一个数组中,并返回新的数组长度。arrayObj.push([item1[item2[...[itemN]]]])2、pop方法(Array)()从数组中移除最后一个元素并返回该元素。arrayObj.pop()可以使用push和pop方法可模拟一个使用先进先出(LIFO)的原则来存储数据的堆栈。push方法..
分类:
编程语言 时间:
2014-11-14 18:06:16
阅读次数:
176
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get ...
分类:
其他好文 时间:
2014-11-13 20:50:45
阅读次数:
197
最近研究邮件备份,首先要使用客户端下载邮件,碰到不少问题:1. HOTMAIL GMAIL SINA的POP/IMAP默认居然都是关闭的,必须改成开放才行。 GMAIL改成开放以后还是没有成功,好像还要再开放一个东西。 最可气的是新浪,还必须绑定手机才能激活POP功能。 yahoo没有这...
分类:
其他好文 时间:
2014-11-13 20:29:59
阅读次数:
165
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes...
分类:
其他好文 时间:
2014-11-13 18:07:10
阅读次数:
212
Redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、 list(链表)、set(集合)、zset(sorted set --有序集合)和hash(哈希类型)。这些数据类型都支持push/pop、add/remove及取...