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.
dict={}
count=0
for i in range(len(s)):
for j in range(i+1,len(s)+1):
list1= list(s[i:j].strip())
list1.sort()
transf=''.join(list1)
if transf in dict:
count+=dict[transf]
dict[transf]=dict[transf]+1
else: dict[transf]=1
return count
Sherlock and Anagrams
You are viewing a single comment's thread. Return to all comments →
My Python 3 Solution