From e6ee7361528dea42029461555a108f32c467a8e2 Mon Sep 17 00:00:00 2001 From: chayan das Date: Mon, 15 Dec 2025 23:55:36 +0530 Subject: [PATCH] Create 2110. Number of Smooth Descent Periods of a Stock --- ... Number of Smooth Descent Periods of a Stock | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 2110. Number of Smooth Descent Periods of a Stock diff --git a/2110. Number of Smooth Descent Periods of a Stock b/2110. Number of Smooth Descent Periods of a Stock new file mode 100644 index 0000000..300ac33 --- /dev/null +++ b/2110. Number of Smooth Descent Periods of a Stock @@ -0,0 +1,17 @@ +class Solution { +public: + long long getDescentPeriods(vector& prices) { + long long ans = 1; + long long len = 1; + + for (int i = 1; i < prices.size(); i++) { + if (prices[i] == prices[i - 1] - 1) { + len++; + } else { + len = 1; + } + ans += len; + } + return ans; + } +};