You are viewing a single comment's thread. Return to all comments →
from collections import Counter from statistics import mode YES = "YES" NO = "NO" def isValid(s): c = Counter(s) m = mode(c.values()) if sum(v for v in c.values() if v != m) - m > 1: return NO if sum(1 for v in c.values() if v != m) > 1: return NO return YES
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and the Valid String
You are viewing a single comment's thread. Return to all comments →
Python 3