You are viewing a single comment's thread. Return to all comments →
from collections import Counter def isValid(s): counts = Counter(Counter(s).values()) match len(counts): case 1: return "YES" case 2: t = list(counts.items()) t = sorted(t, reverse=True) if (t[0][1] == 1 and (t[0][0] - t[1][0]) == 1): return "YES" elif t[-1] == (1, 1): return "YES" else: return "NO" case _: print("default") 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 →