Company: Ibm_23sep
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 consecutive months is considered highly profitable if the stock prices increase strictly throughout those 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. 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 = [3, 5, 7, 8], k = 3 Output: 2 Explanation: The intervals [3, 5, 7] (months 1-3) and [5, 7, 8] (months 2-4) are strictly increasing. Therefore, there are 2 highly profitable i