Skip to content

Instantly share code, notes, and snippets.

@konverner
Last active November 17, 2022 22:29
Show Gist options
  • Save konverner/df7856b6161c7f295d2d6cda8259f714 to your computer and use it in GitHub Desktop.
Save konverner/df7856b6161c7f295d2d6cda8259f714 to your computer and use it in GitHub Desktop.
one line mode in python
arr = [2, 2, 1, 1, 1, -1, -1, 0]
sorted([(i,arr.count(i)) for i in set(arr)], key=lambda x: x[1], reverse=True)[0][0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment