随笔分类 - Stack
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the lo
阅读全文
摘要:The key of this problem is to think of using Stack,
阅读全文
摘要:数组的题常用方法 :排序、最大值指针边走边找、最小值指针边走边找,数组的其他指针位置—顺序遍历, 逆序遍历,其他指针与最大值指针比较的后果或最小值指针 先想排序能否做: Stack 画图: 利用相对位置和大小pop找到最左边的位置, 和最右边的位置, 利用栈内的元素都是最小的特点, 找到要排序的su
阅读全文
摘要:Max Stack: 实现用ddl + treeset. Node n = set.first()
阅读全文
摘要:最好用栈来想问题, 当前元素比栈内元素大 或小的时候怎么办, 最后优化成单个变量, 数组的题除了常用动归, 也常用栈, 用动归前看看解决了重复计算问题吗? 得想出状态转移方程来, 不然就不是动归
阅读全文
摘要:为啥用栈, 数组相对顺序不能变, 要找第一个比当前元素小的元素, 或大的元素, 同84. Largest Rectangle in Histogram 同84. Largest Rectangle in Histogram 在数组后面加"0", 这些操作都是为了遍历所有的元素, 有的不需要遍历所有的
阅读全文
摘要:316. Remove Duplicate Letters321. Create Maximum Number402. Remove K Digits这三道题都用到了 stack 来求原序列中不打乱相对次序的最小子序列的技巧:
阅读全文
摘要:http://blog.csdn.net/u014688145/article/details/72859739
阅读全文
摘要:Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The
阅读全文
摘要:You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1'
阅读全文
摘要:Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai < ak < aj. Design an algorithm th
阅读全文
摘要:Given a nested list of integers represented as a string, implement a parser to deserialize it. Each element is either an integer, or a list -- whose e
阅读全文
摘要:Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. to
阅读全文
摘要:https://leetcode.com/problems/evaluate-reverse-polish-notation/#/description RPN中文名字叫做逆波兰表示法,它的好处维基百科说了,就是不需要括号来表示运算的先后,直接根据式子本身就可以求解。解题思路就是维护一个栈,遇到数字
阅读全文

浙公网安备 33010602011771号