![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
单调栈
文章平均质量分 69
flyatcmu
这个作者很懒,什么都没留下…
展开
-
Number of Visible People in a Queue
There arenpeople standing in a queue, and they numbered from0ton - 1inleft to rightorder. You are given an arrayheightsofdistinctintegers whereheights[i]represents the height of theithperson.A person canseeanother person to their right ...原创 2022-03-30 14:21:02 · 342 阅读 · 0 评论 -
Buildings With an Ocean View
There arenbuildings in a line. You are given an integer arrayheightsof sizenthat represents the heights of the buildings in the line.The ocean is to the right of the buildings. A building has an ocean view if the building can see the ocean without ...原创 2022-01-26 06:07:19 · 462 阅读 · 1 评论 -
Find the Winner of an Array Game
Given an integer arrayarrofdistinctintegers and an integerk.A game will be played between the first two elements of the array (i.e.arr[0]andarr[1]). In each round of the game, we comparearr[0]witharr[1], the larger integerwins and remains at ...原创 2020-08-02 14:21:37 · 172 阅读 · 0 评论 -
单调栈类型总结
Largest Rectangle in Histogram给出的n个非负整数表示每个直方图的高度,每个直方图的宽均为1,在直方图中找到最大的矩形面积。Example样例 1:输入:[2,1,5,6,2,3]输出:10解释:第三个和第四个直方图截取矩形面积为2*5=10。思路:求最大矩阵,就是求每个元素height * 最左边第一个小于他的元素 到右边第一个小于他的...原创 2020-01-12 15:40:41 · 640 阅读 · 0 评论 -
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-10-04 06:42:40 · 243 阅读 · 0 评论 -
Daily Temperatures
Given a list of daily temperaturesT, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which...原创 2020-04-25 05:10:52 · 244 阅读 · 0 评论 -
Shortest Subarray with Sum at Least K
Return thelengthof the shortest, non-empty, contiguoussubarray ofAwith sum at leastK.If there is no non-empty subarray with sum at leastK, return-1.Example 1:Input: A = [1], K = 1Output: 1Example 2:Input: A = [1,2], K = 4Output: -1...原创 2020-06-25 10:44:35 · 312 阅读 · 0 评论 -
Online Stock Span
Write a classStockSpannerwhich collects daily price quotes for some stock, and returns thespanof that stock's price for the current day.The span of the stock's price todayis defined as the maximum number of consecutive days (starting from today and ...原创 2020-06-09 14:02:00 · 197 阅读 · 0 评论 -
Next Greater Node In Linked List
We are given a linked list withheadas the first node. Let's number thenodes in the list:node_1, node_2, node_3, ...etc.Each node may have anext largervalue: fornode_i,next_larger(node_i)is thenode_j.valsuch thatj > i,node_j.val > nod...原创 2020-05-28 13:38:07 · 172 阅读 · 0 评论 -
Next Greater Element II
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 Next Greater Number of a number x is the first greater number to its traversing-order next in the array, w原创 2020-05-25 05:41:38 · 184 阅读 · 0 评论