
Stack
文章平均质量分 73
豆腐脑是咸的
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Evaluate Reverse Polish Notation (Java)
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-01-07 21:45:49 · 359 阅读 · 0 评论 -
Simplify Path (Java)
Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", => "/home" path = "/a/./b/../../c/", => "/c" click to show corner cases. Corner Cases: Did原创 2015-01-23 09:15:32 · 388 阅读 · 0 评论 -
Binary Search Tree Iterator (Java)
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()原创 2015-01-22 16:38:20 · 478 阅读 · 0 评论 -
Binary Tree Inorder Traversal (Java)
Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. Note: Recursive sol原创 2014-12-31 15:17:16 · 465 阅读 · 0 评论 -
Binary Tree Zigzag Level Order Traversal (Java)
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原创 2014-12-31 14:58:21 · 361 阅读 · 0 评论 -
Binary Tree Preorder Traversal (Java)
Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive soluti原创 2014-12-31 15:12:02 · 384 阅读 · 0 评论 -
Min Stack (Java)
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-12-22 21:10:37 · 366 阅读 · 0 评论 -
Valid Parentheses (Java)
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}" are all va原创 2014-10-28 10:07:47 · 513 阅读 · 0 评论 -
Largest Rectangle in Histogram (Java)
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width o原创 2015-02-04 20:56:57 · 394 阅读 · 0 评论 -
Maximal Rectangle (Java)
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. 设一个数组表示从第一行开始遍历的当前列的高度,再用largest rectangle in histogram那道题的方法算最大面积。 Source publ原创 2015-02-05 10:33:20 · 400 阅读 · 0 评论 -
Trapping Rain Water (Java)
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]原创 2015-01-24 11:50:33 · 345 阅读 · 0 评论