栈
liuchenjane
这个作者很懒,什么都没留下…
展开
-
173. Binary Search Tree Iterator
173. Binary Search Tree IteratorImplement 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 small转载 2016-10-21 18:20:59 · 245 阅读 · 0 评论 -
331. Verify Preorder Serialization of a Binary Tree
331. Verify Preorder Serialization of a Binary TreeOne 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 nul原创 2016-11-29 22:35:05 · 300 阅读 · 0 评论 -
341. Flatten Nested List Iterator
341. Flatten Nested List IteratorGiven a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list -- whose elements may also be integers or o转载 2016-11-15 17:16:33 · 305 阅读 · 0 评论 -
456. 132 Pattern
Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such thati j k and ai k j. Design an algorithm that takes a list of n numbers as input and checks whethe转载 2016-12-12 20:50:00 · 288 阅读 · 0 评论 -
迷宫问题
//迷宫问题:求迷宫中从入口到出口的一条路径 //通常用的是“穷举求解”的方法,即从入口出发,顺某一方向向前探索,若能走通,则继续向前走;//否则沿着原路返回,换一个方向再继续探索,直至所有可能的通路都探索到为止//为了保证在任何位置上都能沿着原路返回,需要用一个先进先出的堆栈结构来保存从入口到当前位置的路径/* 可以简单描述如下: do{ 若当前位置可通, 则{原创 2016-11-22 17:20:41 · 407 阅读 · 0 评论 -
150. Evaluate Reverse Polish Notation
150. Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expressi原创 2016-12-17 22:10:21 · 313 阅读 · 0 评论 -
32. Longest Valid Parentheses
iven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()", w转载 2017-01-15 20:16:02 · 304 阅读 · 0 评论 -
84. Largest Rectangle in Histogram
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翻译 2017-02-14 22:13:33 · 322 阅读 · 0 评论