[DAY4]Sherlock and Anagrams

Sherlock Chiou
1 min readOct 14, 2019

--

https://www.hackerrank.com/c…/sherlock-and-anagrams/problem…

Solution: List all the substrings and have them sorted. And we can use the Counter() function to help us build a hash table with the sorted string be the key, the value would be the number of the corresponding string. Because any two identical substrings would form aa anagrammatic pair. So all we need to do is calculate the combination number of the number of the substrings.

--

--

Sherlock Chiou
Sherlock Chiou

Written by Sherlock Chiou

Be Effective and Optimize for Learning

No responses yet