Find Earliest Month
Problem Overview
- Find the earliest month where the net price change is minimized.
- Net change for month i (1 ≤ i < n) is the absolute difference between the averages (rounded down) of months 1..i and months i+1..n.
- Input: int[] stockPrice; Output: integer month index with minimum net change (earliest on ties).
- Real-world context: analyzing sequential stock prices over months.
- Asked in Amazon interviews, this coding interview problem is a common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
