Created
January 17, 2017 12:47
-
-
Save snahor/bb829ce979bebb21573f6fdc9642647b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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