Skip to content

Commit e0486f6

Browse files
authored
Create 2110. Number of Smooth Descent Periods of a Stock (#959)
2 parents 9df34c7 + e6ee736 commit e0486f6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
long long getDescentPeriods(vector<int>& prices) {
4+
long long ans = 1;
5+
long long len = 1;
6+
7+
for (int i = 1; i < prices.size(); i++) {
8+
if (prices[i] == prices[i - 1] - 1) {
9+
len++;
10+
} else {
11+
len = 1;
12+
}
13+
ans += len;
14+
}
15+
return ans;
16+
}
17+
};

0 commit comments

Comments
 (0)