You are viewing a single comment's thread. Return to all comments →
python (NOTE replace '@' with ':' - HackerRank didn't allow to upload this comment when having ':' in the text).
import itertools def sherlockAndAnagrams(s): return sum([ len([ pair for pair in itertools.combinations([s[i@i+l] for i in range(len(s) - l + 1)], 2) if sorted(pair[0]) == sorted(pair[1]) ]) for l in range(1, len(s)) ])
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Anagrams
You are viewing a single comment's thread. Return to all comments →
python (NOTE replace '@' with ':' - HackerRank didn't allow to upload this comment when having ':' in the text).