leetcode

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

2110.cpp (327B)


0 class Solution { 1 public: 2 long long getDescentPeriods(const vector<int> &prices) const { 3 long long res = 1, cnt = 1; 4 const int n = prices.size(); 5 for (int i = 1; i < n; i++) { 6 if (prices[i] + 1 != prices[i - 1]) cnt = 0; 7 res += ++cnt; 8 } 9 return res; 10 } 11 };