1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/股票平滑下跌阶段的数目 [number-of-smooth-descent-periods-of-a-stock].html
2022-03-29 12:43:11 +08:00

41 lines
1.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个整数数组&nbsp;<code>prices</code>&nbsp;,表示一支股票的历史每日股价,其中&nbsp;<code>prices[i]</code>&nbsp;是这支股票第&nbsp;<code>i</code>&nbsp;天的价格。</p>
<p>一个 <strong>平滑下降的阶段</strong>&nbsp;定义为:对于&nbsp;<strong>连续一天或者多天</strong>&nbsp;,每日股价都比 <strong>前一日股价恰好少 </strong><code>1</code>&nbsp;,这个阶段第一天的股价没有限制。</p>
<p>请你返回 <strong>平滑下降阶段</strong>&nbsp;的数目。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><b>输入:</b>prices = [3,2,1,4]
<b>输出:</b>7
<b>解释:</b>总共有 7 个平滑下降阶段:
[3], [2], [1], [4], [3,2], [2,1] 和 [3,2,1]
注意,仅一天按照定义也是平滑下降阶段。
</pre>
<p><strong>示例 2</strong></p>
<pre><b>输入:</b>prices = [8,6,7,7]
<b>输出:</b>4
<b>解释:</b>总共有 4 个连续平滑下降阶段:[8], [6], [7] 和 [7]
由于 8 - 6 ≠ 1 ,所以 [8,6] 不是平滑下降阶段。
</pre>
<p><strong>示例 3</strong></p>
<pre><b>输入:</b>prices = [1]
<b>输出:</b>1
<b>解释:</b>总共有 1 个平滑下降阶段:[1]
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= prices.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= prices[i] &lt;= 10<sup>5</sup></code></li>
</ul>