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.
fromcollectionsimportdefaultdictdefconvertDecimal(date):base=date[0]n=date[1]ifbase<=1:return-1decimal=0d=1while(n):r=n%10ifr>=base:return-1decimal+=r*dd*=basen=n//10returndecimaldefsolve(dates):# Write your code herecount=0ans=0# dates = list(set(tuple (d) for d in dates))di=defaultdict(int)fordateindates:x=convertDecimal(date)ifx==-1:continuedi[x]+=1ans=0forfreqindi.values():ans+=(freq*(freq-1))// 2returnans
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Jim and the Jokes
You are viewing a single comment's thread. Return to all comments →