Did you mean: Jatin is a college student and he got his first salary from an internship. his plan is to buy one stock on a particular day and then sell it on another day. He can trade (buy & sell) the stock only once. he has one time use magic spell which he used to get the stock prices N future consecutive days. based on this information and his strategy determine the maximum profit he can make. in the given list of price, the price of stock on the ith day is denoted by prices[i]. If there is no profit that can be achieved , return 0.
SAMPLE INPUT 1:
7 1 5 3 6 4
SAMPLE OUTPUT 1:
5
SAMPLE INPUT 2:
1 11 13 21 19
SAMPLE OUTPUT 2:
20
arr = list(map(int,input().split()))
Min = 100000000
Max = 0
for it in arr:
Min = min(Min,it)
Max = max(Max,it-Min)
print(Max)
Comments
Leave a comment