You are given a list of prices, where price [ i ] is the price of a given stock on the i th day
Write a program to print the maximum profit by choosing a single day to buy a stock and choosing a different day in the future to sell that stock
If there is no profit that can be achived return 0
Input:
The input is a single line containing space - separated integers
output:
The output should be a an integer
sample Input1:
7 1 5 3 6 4
sampleoutput1:
5
sampleinput2:
1 11 13 21 19
sample output2:
20
#Price = [7, 1, 5, 3, 6, 4]
P = input("Enter Price followed by SPACE: ")
P = str(P).split(" ")
Price=[]
for r in range(0,len(P)):
Price.append(int(P[r]))
Profit = max(Price)-min(Price)
print(Profit)
Comments
Leave a comment