Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. def sherlockAndAnagrams1(s):
  2. count = 0; chars = 1
  3. while chars < len(s):
  4. for i in range(len(s)-1):
  5. for j in range(i+1, len(s)):
  6. if j + chars > len(s):
  7. break
  8. source = sorted(s[i:i+chars])
  9. dest = sorted(s[j:j+chars])
  10.  
  11. if source == dest:
  12. count += 1
  13. chars += 1
  14. return count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement