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.
c = set(s)
l = []
result = "YES"
for i in c:
k = s.count(i)
l.append(k)
if(max(l) == min(l)):
return result
if(max(l)-min(l)== 1):
if(l.count(min(l))<2 or l.count(max(l))<2):
return result
else:
result = "NO"
return result
if(min(l) == 1 and l.count(min(l)==1) and l.count(max(l))==len(l)-1):
return result
else:
result = "NO"
return result
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 →
def isValid(s):