Skip to content

Commit ae844b3

Browse files
committed
Create README - LeetHub
1 parent 2a380e9 commit ae844b3

File tree

1 file changed

+41
-0
lines changed
  • 2110-number-of-smooth-descent-periods-of-a-stock

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<h2><a href="https://leetcode.com/problems/number-of-smooth-descent-periods-of-a-stock">2233. Number of Smooth Descent Periods of a Stock</a></h2><h3>Medium</h3><hr><p>You are given an integer array <code>prices</code> representing the daily price history of a stock, where <code>prices[i]</code> is the stock price on the <code>i<sup>th</sup></code> day.</p>
2+
3+
<p>A <strong>smooth descent period</strong> of a stock consists of <strong>one or more contiguous</strong> days such that the price on each day is <strong>lower</strong> than the price on the <strong>preceding day</strong> by <strong>exactly</strong> <code>1</code>. The first day of the period is exempted from this rule.</p>
4+
5+
<p>Return <em>the number of <strong>smooth descent periods</strong></em>.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre>
11+
<strong>Input:</strong> prices = [3,2,1,4]
12+
<strong>Output:</strong> 7
13+
<strong>Explanation:</strong> There are 7 smooth descent periods:
14+
[3], [2], [1], [4], [3,2], [2,1], and [3,2,1]
15+
Note that a period with one day is a smooth descent period by the definition.
16+
</pre>
17+
18+
<p><strong class="example">Example 2:</strong></p>
19+
20+
<pre>
21+
<strong>Input:</strong> prices = [8,6,7,7]
22+
<strong>Output:</strong> 4
23+
<strong>Explanation:</strong> There are 4 smooth descent periods: [8], [6], [7], and [7]
24+
Note that [8,6] is not a smooth descent period as 8 - 6 &ne; 1.
25+
</pre>
26+
27+
<p><strong class="example">Example 3:</strong></p>
28+
29+
<pre>
30+
<strong>Input:</strong> prices = [1]
31+
<strong>Output:</strong> 1
32+
<strong>Explanation:</strong> There is 1 smooth descent period: [1]
33+
</pre>
34+
35+
<p>&nbsp;</p>
36+
<p><strong>Constraints:</strong></p>
37+
38+
<ul>
39+
<li><code>1 &lt;= prices.length &lt;= 10<sup>5</sup></code></li>
40+
<li><code>1 &lt;= prices[i] &lt;= 10<sup>5</sup></code></li>
41+
</ul>

0 commit comments

Comments
 (0)