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.
You are right, I didn`t cinsidering this situation. I change my code (function compare(b)),use regular expression:
importredefcalculate(n,b):# find if exists any single letterifb.count("_")==0andlen(re.sub(r'((.)\2+)',"",b))!=0:return"NO"forainset(b):ifa!="_"andb.count(a)==1:return"NO"return"YES"for_inrange(int(input())):n=int(input())b=input()print(calculate(n,b))
more concise! Thanks!
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 →
You are right, I didn`t cinsidering this situation. I change my code (function compare(b)),use regular expression:
more concise! Thanks!