Skip to content

Instantly share code, notes, and snippets.

@volf52
Created November 30, 2019 11:59
Show Gist options
  • Save volf52/b7134b987315f57ddc1c00abdb2f3293 to your computer and use it in GitHub Desktop.
Save volf52/b7134b987315f57ddc1c00abdb2f3293 to your computer and use it in GitHub Desktop.
Second highest number in array
def second_highest(iterable, key = lambda x: x):
highest = -1
second = -1
for i in iterable:
o = key(i)
if(o > highest):
second, highest = highest, o
elif(o > second):
second = o
return second
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment