Tap here to switch tabs
Problem
Submissions

Problem: Number of Smooth Descent Periods of a Stock

med
30 min
Try to solve the Number of Smooth Descent Periods of a Stock problem.

Statement

You are given an integer array prices representing the daily price of a stock.

A smooth descent period of a stock consists of one or more contiguous days such that the price on each day is lower than the price on the preceding day by exactly 11. Specifically, for any consecutive days in the period, the condition prices[i] - prices[i + 1] =1= 1 holds.

Return the total number of smooth descent periods.

Note: A period consisting of a single day is also considered a smooth descent period.

Constraints:

  • 1≤1 \leq prices.length ≤105\leq 10^5

  • 1≤1 \leq prices[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Smooth Descent Periods of a Stock

med
30 min
Try to solve the Number of Smooth Descent Periods of a Stock problem.

Statement

You are given an integer array prices representing the daily price of a stock.

A smooth descent period of a stock consists of one or more contiguous days such that the price on each day is lower than the price on the preceding day by exactly 11. Specifically, for any consecutive days in the period, the condition prices[i] - prices[i + 1] =1= 1 holds.

Return the total number of smooth descent periods.

Note: A period consisting of a single day is also considered a smooth descent period.

Constraints:

  • 1≤1 \leq prices.length ≤105\leq 10^5

  • 1≤1 \leq prices[i] ≤105\leq 10^5