Skip to content

Commit

Permalink
Create Stockpriceprofit.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nihirgupta committed Oct 30, 2020
1 parent aa64228 commit 04c08ac
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Stockpriceprofit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def stockprice(price):
minuptil = [0]*len(price)
profit = [0]*len(price)
minuptil[0] = price[0]
for i in range(1,len(price)):
minuptil[i] = min(price[i],minuptil[i-1])
profit[i] = price[i] - minuptil[i]
return max(profit)
print(stockprice([8,1,2,4,6,3]))

0 comments on commit 04c08ac

Please sign in to comment.