You are viewing a single comment's thread. Return to all comments →
from collections import Counter def isValid(s): c = dict(sorted(Counter(Counter(s).values()).items())) return 'YES' if (len(c) == 1 or (len(c) == 2 and ((list(c.keys())[1] - list(c.keys())[0] == 1 and list(c.values())[1] == 1) or c.get(1) == 1))) else 'NO'
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Sherlock and the Valid String
You are viewing a single comment's thread. Return to all comments →