You are viewing a single comment's thread. Return to all comments →
Insane python solution:
def isValid(s): counts_dict = {} for c in s: counts_dict[c] = counts_dict.get(c,0) + 1 counts = counts_dict.values() counts_len = len(counts) min_num = min(counts) max_num = max(counts) counts_sum = sum(counts) return "YES" if min_num*counts_len == counts_sum or min_num*counts_len+1 == counts_sum or max_num*(counts_len-1)+1==counts_sum else "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 →
Insane python solution: