Skip to content

Instantly share code, notes, and snippets.

@imedadel
Created November 3, 2019 20:43
Show Gist options
  • Select an option

  • Save imedadel/4f11632bdadd57ec6635ed81e56d977c to your computer and use it in GitHub Desktop.

Select an option

Save imedadel/4f11632bdadd57ec6635ed81e56d977c to your computer and use it in GitHub Desktop.
from collections import Counter
word = input().strip()
def sherlock(word):
freq = Counter(word)
freqFreq = Counter(freq.values())
hasVarFreq = len(freqFreq.values()) > 2 or min(freqFreq.values()) != 1
if hasVarFreq:
return "NO"
return "YES"
print(sherlock(word))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment