Chef and Loss SOLUTIONS CHEF1003

Chef and Loss SOLUTION

Culinary expert has a diagram of costs for an eatery throughout the following quite a while. He should purchase the eatery in one year and sell it in another, and he should do as such at a misfortune. He needs to limit budgetary misfortune with your assistance. 

Information: 

The principal line contains a whole number n, the quantity of long periods of house information. 

The subsequent line contains n space-isolated long numbers portraying each Price[i] . 

 

Yield: 

Print a solitary whole number signifying the base measure of cash Chef must lose on the off chance that he purchases and exchanges the house inside the following years. 

 

Imperatives 

2≤n≤2X105 

1≤Price[i]≤1016 

 

Test Input: 

5 10 3 

 

Test Output: 

 

Clarification: 

Gourmet specialist purchases the eatery in year 1 at price[0]=5 and sells it in year 3 at price[2]=3 for an insignificant loss of 5−3=2. Consequently the appropriate response is 

2.

Leave a Comment

close
error: Content is protected !!