
栈
qq_30339595
人类,诗意地栖息在大地上。
展开
-
leetcode114 Flatten Binary Tree to Linked List
the purpose of this question is to let you recover the memory about post order tranverse. Just as the post order tranverse, to solve this problem,you have to solve the left subtree of the root and the...原创 2019-11-15 20:07:10 · 119 阅读 · 0 评论 -
leetcode 85. Maximal Rectangle
这道题和84这道题非常类似,唯一不同的地方就是这道题需要遍历每一行,套用84这道题的思路,这道题就是每一行上面有高低参差不齐的柱子,求每一行上面的最大矩形,最后取最大值就是最大的矩形。 最大矩形怎么求的问题再重申一遍。 建立一个栈,这个栈里面装的都是依次从后往前递减的小于该高度的位置索引。 对于栈里面大于该高度的,就pop出来,并计算面积(j-stack[-1]-1)*h class Soluti...原创 2019-11-07 10:21:28 · 118 阅读 · 0 评论