You are viewing a single comment's thread. Return to all comments →
def minimumLoss(price): price_idx = {} n = len(price) price_limit = math.pow(10, 16) for p in range(n): price_idx[price[p]] = p price.sort() for i in range(n-1): buying_price = price[i] selling_price = price[i + 1] diff = abs(buying_price - selling_price) buying_price_idx = price_idx.get(buying_price) selling_price_idx = price_idx.get(selling_price) if buying_price_idx > selling_price_idx and diff <= price_limit: price_limit = diff return price_limit
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Loss
You are viewing a single comment's thread. Return to all comments →