Skip to content

Instantly share code, notes, and snippets.

@slapec
Created March 17, 2021 20:42
Show Gist options
  • Save slapec/26830cf8ad16235af10f608b7ea5c688 to your computer and use it in GitHub Desktop.
Save slapec/26830cf8ad16235af10f608b7ea5c688 to your computer and use it in GitHub Desktop.
import collections
def smallest_unique_number(numbers: list) -> int:
try:
least_common, population = collections.Counter(numbers).most_common()[-1]
assert population == 1
return least_common
except (AssertionError, IndexError):
return -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment