Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sherlockAndAnagrams1(s):
- count = 0; chars = 1
- while chars < len(s):
- for i in range(len(s)-1):
- for j in range(i+1, len(s)):
- if j + chars > len(s):
- break
- source = sorted(s[i:i+chars])
- dest = sorted(s[j:j+chars])
- if source == dest:
- count += 1
- chars += 1
- return count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement