Skip to content

Instantly share code, notes, and snippets.

@shamikalashawn
Created February 1, 2017 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shamikalashawn/86d6da00d1ab9e94a1fb646ce470ea61 to your computer and use it in GitHub Desktop.
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.
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