2110. Number of Smooth Descent Periods of a Stock
Содержание
class Solution:
def getDescentPeriods(self, prices: List[int]) -> int:
res = 0
i, n = 0, len(prices)
while i < n:
j = i + 1
while j < n and prices[j - 1] - prices[j] == 1:
j += 1
cnt = j - i
res += (1 + cnt) * cnt // 2
i = j
return res