{"size": 322, "ext": "js", "max_stars_repo_path": "leetcode/contest-272/5958. Number of Smooth Descent Periods of a Stock.js", "max_stars_repo_name": "upupming/algorithm", "max_stars_repo_stars_event_min_datetime": "2019-10-25T07:46:59.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-29T11:10:56.000Z", "max_issues_repo_path": "leetcode/contest-272/5958. Number of Smooth Descent Periods of a Stock.js", "max_issues_repo_name": "upupming/algorithm", "max_issues_repo_issues_event_min_datetime": "2021-08-13T05:42:27.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-13T05:42:27.000Z", "max_forks_repo_path": "leetcode/contest-272/5958. Number of Smooth Descent Periods of a Stock.js", "max_forks_repo_name": "upupming/algorithm", "max_forks_repo_forks_event_min_datetime": "2020-12-09T14:24:22.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T06:56:01.000Z"}
{"max_stars_count": 107, "max_issues_count": 1, "max_forks_count": 18, "avg_line_length": 18.9411764706, "max_line_length": 50, "alphanum_fraction": 0.4658385093}
/**
 * @param {number[]} prices
 * @return {number}
 */
const getDescentPeriods = function (p) {
  const n = p.length
  let ans = 0
  for (let i = 0; i < p.length; i++) {
    let j = i
    while (j + 1 < n && p[j + 1] === p[j] - 1) j++
    const len = j - i + 1
    ans += len * (len + 1) / 2
    i = j
  }
  return ans
}
