#K92362. Highest Sales Spike Detection
Highest Sales Spike Detection
Highest Sales Spike Detection
A retailer wants to analyze daily sales data of a product to determine the day with the highest sales spike. The sales data is provided for N days and each day is associated with the number of units sold. Your task is to identify the first day on which the sales spike—defined as the difference between the sales of the current day and the previous day—is the largest. Formally, for a day i (with 2 \leq i \leq N), the spike is given by:
$\Delta_i = sales_i - sales_{i-1}$
If no day exhibits a positive increase compared to the previous day, output -1
. Note that days are 1-indexed.
inputFormat
The first line of input contains an integer N indicating the number of days for which sales data is available. The second line contains N space-separated integers representing the number of units sold on each day.
outputFormat
Output a single integer which is the 1-based index of the first day that has the highest sales spike. If there is no positive spike, output -1
.
7
10 20 30 25 50 35 55
5