Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def max_difference(xs):
max = min = xs[0]
d = -1
for x in xs[1:]:
if min > x:
min = max = x
continue
if x > max:
max = x
if max - min > d:
d = max - min
return d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment