Skip to content

Instantly share code, notes, and snippets.

@snahor
Created January 17, 2017 12:47
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 snahor/bb829ce979bebb21573f6fdc9642647b to your computer and use it in GitHub Desktop.
Save snahor/bb829ce979bebb21573f6fdc9642647b to your computer and use it in GitHub Desktop.
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