We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defisValid(s):# Write your code herecount=Counter(s).values()countvalues=Counter(count)iflen(countvalues)>2:return'NO'eliflen(countvalues)==1:return'YES'val=min(countvalues.keys())val2=max(countvalues.keys())ifabs(val2-val)>1:ifval!=1orcountvalues[1]>1:return'NO'ifmin(countvalues.values())>1:return'NO'return'YES'
Cookie support is required to access HackerRank
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 →