Number of Smooth Descent Periods of a Stock LeetCode solution in JavaScript
1var getDescentPeriods = function (prices) {2const n = prices.length;34let left = 0;5let totRes = 0;67while (left < n) {8let count = 1;910let right = left + 1;1112while (right < n && prices[right] + 1 === prices[right - 1]) {13count += right - left + 1;14++right;15}1617totRes += count;1819left = right;20}2122return totRes;23};