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.
count_b = Counter(b)
mc = count_b.most_common()
if len(mc)!=1 and ((mc[-1][1]== 1 and mc[-1][0]!= '_') or mc[-2][1]== 1):
return 'NO'
else:
if '_' in b:
return 'YES'
for i in mc:
if count_b[i[0]]==1 or b.rfind(i[0])-b.find(i[0])+1 != count_b[i[0]]:
return 'NO'
if i == mc[-1]:
return 'YES'
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Happy Ladybugs
You are viewing a single comment's thread. Return to all comments →
from collections import Counter
def happyLadybugs(b):