Company: Ibm_22sep
Difficulty: medium
Highly Profitable Intervals Problem Description The stock performance of a company is being examined to assess its net profit over time. For a given analysis parameter k , an interval of k months is said to be highly profitable if the stock prices increase strictly throughout those k months. Given the stock prices for n months and the analysis parameter k , determine the number of such highly profitable intervals. Note: If the interval length is 1, each subarray of length 1 is highly profitable. Complete the function countHighlyProfitableIntervals in the editor below. The function countHighlyProfitableIntervals has the following parameters: int stockPrices[n] : the stock prices for n months int k : the analysis parameter Returns: int : the number of highly profitable intervals Examples Example 1: Input: stockPrices = [5, 3, 5, 7, 8], k = 3 Output: 2 Explanation: The intervals of length 3 are: [5, 3, 5] : Not strictly increasing (5 is not > 3) [3, 5, 7] : Strictly increasing [5, 7, 8