You are viewing a single comment's thread. Return to all comments →
PYTHON 3 CODE
def isValid(s): news=set(s) newsort=sorted(news) key=[0]*len(newsort) for i in range(len(s)): if s[i] in newsort: x=newsort.index(s[i]) key[x]+=1 if(all(element == key[0] for element in key)): return "YES" elif max(key)-1==min(key) and ( key.count(max(key)))==1: return "YES" elif max(key)-1==min(key) and ( key.count(min(key)))==1: return "YES" elif(key.count(max(key))==len(key)-1) and min(key)==1: return "YES" else: 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 →
PYTHON 3 CODE