We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defstockmax(prices):# Write your code herex=max(prices)firstIndex=prices.index(x)if(firstIndex==0):res=0else:res=-1*sum(prices[0:firstIndex])+firstIndex*xif(firstIndex+1==len(prices)):returnreselse:returnres+stockmax(prices[firstIndex+1:])
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Stock Maximize
You are viewing a single comment's thread. Return to all comments →