2110. Number of Smooth Descent Periods of a Stock, DP, 1D type
- cakewalk
- just observe what kind of thing you have to save
- and then go along
Code
```cpp
long long getDescentPeriods(vector& prices) {
int n = prices.size();
vector dp(n, 1);
for (int i = 1; i < n; i++) {
if (prices[i - 1] == prices[i] + 1) {
dp[i] += dp[i - 1];
}
}
long long sum = 0;
for (const auto & i: dp) {
cout << i << ' ';
sum += i;
}
return sum;
```
</details>