You are viewing a single comment's thread. Return to all comments →
9 Lines in python
n = int(input()) price = list(map(int, input().rstrip().split())) sortedprice = sorted(price, reverse = True) minloss = sortedprice[0] for x in range(len(sortedprice)-1): if (sortedprice[x] - sortedprice[x+1]) < minloss: if price.index(sortedprice[x]) < price.index(sortedprice[x+1]): minloss = (sortedprice[x] - sortedprice[x+1]) print(minloss)
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 →
9 Lines in python