Company: amazon_23april
Difficulty: medium
Code Question 2 Data Analysts at Amazon are analyzing sales patterns. Based on their analysis, the team concluded that whenever a limited-period offer is rolled out, there is a spike in sales on the first and last days of the offer. They classify a period of 3 or more days as an offer period if the minimum value of the sales on the first and last days of the period outweigh the maximum value of sales on all other days in that period. In mathematical terms, a period of days[i,j](1 ≤ i ≤ n-2 and i+1 ≤ j ≤ n) is classified as an offer period if: The period [i,j] is an offer period if: 1≤ i ≤ n-2 i+1 ≤ j ≤ n min(sales[i], sales[j]) > max(sales[i+1], sales[i+2], ..., sales[j-1]) Given an array of distinct integers, sales, with sales statistics over a period of n consecutive days, report the number of offer periods identified. Function Description Complete the function getTotalOfferPeriods in the editor below. getTotalOfferPeriods has the following parameter: int sales[n]: the sales statisti