leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit 8c0b864dd7b3a51ce9b72aab16f11704ede5a585
parent 013369eedc52341ac18f47bf0d31613b7c9c35e4
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon, 20 Nov 2023 22:36:37 +0000

1 Random Problem

Diffstat:
AProblems/2110.cpp | 12++++++++++++
MREADME.md | 1+
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/Problems/2110.cpp b/Problems/2110.cpp @@ -0,0 +1,12 @@ +class Solution { + public: + long long getDescentPeriods(const vector<int> &prices) const { + long long res = 1, cnt = 1; + const int n = prices.size(); + for (int i = 1; i < n; i++) { + if (prices[i] + 1 != prices[i - 1]) cnt = 0; + res += ++cnt; + } + return res; + } +}; diff --git a/README.md b/README.md @@ -784,6 +784,7 @@ for solving problems. | 2095 | Medium | [Delete the Middle Node of a Linked List](Problems/2095.cpp) | | 2101 | Medium | [Detonate the Maximum Bombs](Problems/2101.cpp) | | 2104 | Medium | [Sum of Subarray Ranges](Problems/2104.cpp) | +| 2110 | Medium | [Number of Smooth Descent Periods of a Stock](Problems/2110.cpp) | | 2115 | Medium | [Find All Possible Recipes from Given Supplies](Problems/2115.cpp) | | 2120 | Medium | [Execution of All Suffix Instructions Staying in a Grid](Problems/2120.cpp) | | 2125 | Medium | [Number of Laser Beams in a Bank](Problems/2125.cpp) |