Company: Nxtwave_13dec
Difficulty: medium
Yet Another Counting Problem Yet Another Counting Problem Description In a small town, Alice is recording the daily price of a gem in an array prices of size n , where prices[i] is the price on the i -th day. She notices that sometimes the prices form a smooth fall : each day's price is exactly 1 less than the previous day's price. Alice defines a smooth fall period as any set of consecutive days where this condition holds. Even a single day is considered a smooth fall period. Your task is to help Alice count the total number of smooth fall periods in the array. Example 1 Input: n = 4 prices = [3, 2, 1, 4] Output: 7 Explanation: The smooth fall periods are [3], [2], [1], [4], [3,2], [2,1], and [3,2,1]. So there are 7 in total. Example 2 Input: n = 4 prices = [8, 6, 7, 7] Output: 4 Explanation: Only the single-day periods [8], [6], [7], [7] are valid. For example, [8,6] is not valid because the difference is 2, not 1. Constraints 1 <= n <= 10 5 1 <= prices[i] <= 10 5 Input F