You are viewing a single comment's thread. Return to all comments →
Counter is nice.
def isValid(s): counts = dict(Counter(s)) count_freqs = dict(Counter(counts.values())) if len(count_freqs) == 1: return 'YES' elif len(count_freqs) > 2: return 'NO' elif count_freqs.get(1, 0) == 1: return 'YES' elif abs(list(count_freqs.keys())[-1] - list(count_freqs.keys())[0]) == 1 and count_freqs[max(list(count_freqs.keys()))] == 1: return 'YES' return 'NO'
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 →
Counter is nice.