Two strings are anagrams of each other if the letters of one string can be rearranged to form the other string. e.g Stressed = Desserts, Bored = Robed, etc.
Write a function that given a string, find the number of pairs of substrings of the string that are anagrams of each other.
For example s = mom, the list of all anagrammatic pairs is [m,m], [mo,om].
Therefore, the answer is 2.
explanation:
e.g for the string "mom", here are the substrings
The square brackets are the range that makes the substring
Two strings are anagrams of each other if the letters of one string can be rearranged to form the other string. e.g
Stressed = Desserts
,Bored = Robed
, etc.Write a function that given a string, find the
number of pairs of substrings
of the string that are anagrams of each other.For example
s = mom
, the list of all anagrammatic pairs is[m,m], [mo,om]
. Therefore, the answer is 2.explanation: e.g for the string "mom", here are the substrings The square brackets are the range that makes the substring
so from all those substrings, these are anagrams of each other