Skip to content

Commit

Permalink
Merge pull request #117 from nihirgupta/master
Browse files Browse the repository at this point in the history
Create Stockpriceprofit.py
  • Loading branch information
fineanmol committed Oct 30, 2020
2 parents 9639808 + 04c08ac commit 64764c2
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 64764c2

Please sign in to comment.