
Stack
文章平均质量分 76
dyllanzhou
这个作者很懒,什么都没留下…
展开
-
[Leetcode]Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1", "+",原创 2015-11-10 22:46:49 · 259 阅读 · 0 评论 -
[Leetcode]Remove Duplicate Letters
Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order a原创 2016-01-29 12:15:19 · 457 阅读 · 0 评论 -
[cc150]Chapter 3 | Stacks and Queues
Describe how you could use a single array to implement three stacks.1)solution 1 divide the array to 3 part, so each part can be one stack, but for each stack is limited to n/3 size [stk1][stk原创 2015-12-04 14:42:51 · 317 阅读 · 0 评论 -
[Leetcode]Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solution is tri原创 2015-12-03 18:10:20 · 249 阅读 · 0 评论 -
[Leetcode]Simplify Path
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"class Solution {public: /*algorithm for simplici原创 2015-11-14 22:06:12 · 272 阅读 · 0 评论 -
[Leetcode]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 level and alternate between).For example:Given binary tr原创 2015-10-27 00:03:15 · 335 阅读 · 0 评论 -
[Leetcode] Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].Note: Recursive solution is triv原创 2015-09-14 11:14:32 · 245 阅读 · 0 评论 -
[Leetcode]Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Note: Recursive solution is trivi原创 2015-09-22 11:44:33 · 305 阅读 · 0 评论 -
[Leetcode]Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next() and原创 2015-10-11 11:44:37 · 272 阅读 · 0 评论 -
[Leetcode]Verify Preorder Serialization of a Binary Tree
One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as#.原创 2016-03-15 18:51:00 · 334 阅读 · 0 评论