
queue
文章平均质量分 80
jialuyyy
这个作者很懒,什么都没留下…
展开
-
implement a queue using stack
//implement a queue using stack public class Solution { Stack stack1 = new Stack(); Stack stack2 = new Stack(); //pop: dequeue in stack1 public void dequeue() { if (stack1.peek()原创 2015-06-17 12:34:48 · 216 阅读 · 0 评论 -
implement a stack using queue
Use two queues to implement stack. q2 is used to make sure the new element is always at the front of the q1. public class Solution { Queue q1 = new LinkedList(); Queue q2 = new LinkedList(原创 2015-06-17 12:25:46 · 237 阅读 · 0 评论 -
Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next leve原创 2015-06-06 22:26:15 · 183 阅读 · 0 评论 -
Populating Next Right Pointers in Each Node I, II
Populating Next Right Pointers in Each Node Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } P原创 2015-06-07 22:42:01 · 209 阅读 · 0 评论