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.
defabbreviation(a,b):# Write your code hereresults,valid,last={''},False,Falsefori,charinenumerate(a):new=set()last=i==len(a)-1forresultinresults:less=len(result)<len(b)ifchar.isupper():iflast:valid=result+char==belifless:new.add(result+char)else:temp=result+char.upper()iflast:valid=b==resultorb==tempifnotlast:new.add(result)iflessandb.startswith(temp):new.add(temp)iflastandvalid:return'YES'results=newreturn'NO'
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Abbreviation
You are viewing a single comment's thread. Return to all comments →