We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Minimum Loss 1
Minimum Loss 1
Minimum Loss 1
Lauren has a chart of distinct projected prices for a house over the next several years. She must buy the house in one year and sell it in another, and she must do so at a loss. She wants to minimize her financial loss.
Example
Her minimum loss is incurred by purchasing in year at and reselling in year at . Return .
Function Description
Complete the minimumLoss function in the editor below.
minimumLoss has the following parameter(s):
- int price[n]: home prices at each year
Returns
- int: the minimum loss possible
Input Format
The first line contains an integer , the number of years of house data.
The second line contains space-separated long integers that describe each .
Constraints
- All the prices are distinct.
- A valid answer exists.
Subtasks
- for of the maximum score.