Skip to content

Instantly share code, notes, and snippets.

@kiramishima
Created September 20, 2021 18:27
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 kiramishima/ca13165f3511791c39c12664981a373b to your computer and use it in GitHub Desktop.
Save kiramishima/ca13165f3511791c39c12664981a373b to your computer and use it in GitHub Desktop.
Mi solucion del 2
def MaxProfit(priceAsString):
list = [int(i) for i in priceAsString.split(',')]
print(list)
minVal = min(list)
indexMinVal = list.index(minVal)
if indexMinVal < len(list):
list2 = list[indexMinVal::]
if len(list2) == 1:
return 0
elif len(list2) <= 2:
list.pop(indexMinVal)
d = ','.join(str(e) for e in list)
return MaxProfit(d)
else:
maxVal = max(list[indexMinVal::])
indexMaxVal = list.index(maxVal)
return maxVal - minVal
else:
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment