Skip to content

Instantly share code, notes, and snippets.

@ypercube
Last active August 29, 2015 14:07
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 ypercube/661e123ba61fc8dc2ab1 to your computer and use it in GitHub Desktop.
Save ypercube/661e123ba61fc8dc2ab1 to your computer and use it in GitHub Desktop.
stream = [1,2,3,4,5,6,7,7,7,7]
def maxN(stream, n):
result = []
for i in stream:
if i not in result:
result.append(i)
result.sort(reverse=True)
result = result[0:n]
return result
print( maxN(stream, 3) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment