mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
存量题库数据更新
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
<p>Design an algorithm that collects daily price quotes for some stock and returns <strong>the span</strong> of that stock's price for the current day.</p>
|
||||
|
||||
<p>The <strong>span</strong> of the stock's price today is defined as the maximum number of consecutive days (starting from today and going backward) for which the stock price was less than or equal to today's price.</p>
|
||||
<p>The <strong>span</strong> of the stock's price in one day is the maximum number of consecutive days (starting from that day and going backward) for which the stock price was less than or equal to the price of that day.</p>
|
||||
|
||||
<ul>
|
||||
<li>For example, if the price of a stock over the next <code>7</code> days were <code>[100,80,60,70,60,75,85]</code>, then the stock spans would be <code>[1,1,1,2,1,4,6]</code>.</li>
|
||||
<li>For example, if the prices of the stock in the last four days is <code>[7,2,1,2]</code> and the price of the stock today is <code>2</code>, then the span of today is <code>4</code> because starting from today, the price of the stock was less than or equal <code>2</code> for <code>4</code> consecutive days.</li>
|
||||
<li>Also, if the prices of the stock in the last four days is <code>[7,34,1,2]</code> and the price of the stock today is <code>8</code>, then the span of today is <code>3</code> because starting from today, the price of the stock was less than or equal <code>8</code> for <code>3</code> consecutive days.</li>
|
||||
</ul>
|
||||
|
||||
<p>Implement the <code>StockSpanner</code> class:</p>
|
||||
@@ -14,7 +15,7 @@
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input</strong>
|
||||
|
Reference in New Issue
Block a user