Created
February 1, 2017 02:17
-
-
Save shamikalashawn/86d6da00d1ab9e94a1fb646ce470ea61 to your computer and use it in GitHub Desktop.
Given a list of stock prices, this function returns the highest profit possible if bought at the lowest price and sold at the highest.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def market_analyze(price_arr): | |
min = price_arr[0] | |
max = price_arr[0] | |
for num in price_arr: | |
if num < min: | |
min = num | |
print min | |
for num in price_arr: | |
if num > max: | |
max = num | |
print max | |
return max - min |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment