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.
# Write your code here
s_dict = {}
count=0
for i in s:
if i in s_dict:
s_dict[i]+=1
else:
s_dict[i]=1
dict_val_list = list(s_dict.values())
for i in range(1,len(s_dict)):
if dict_val_list[0] == dict_val_list[i]:
continue
else:
if count==0:
count+=1
else:
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 →
python -
def isValid(s):