We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Sherlock and Anagrams
Sherlock and Anagrams
Sort by
recency
|
1678 Discussions
|
Please Login in order to post a comment
C#
Am I the only one who ended up using the binomial coefficient to work out how many pairs multiple occurances of the same string makes?
Maybe I overcomplicated it but it makes the rest real simple: - Generate every substring - Make a unique ref for the characters in that substring by ordering and hashing it - Get the frequency of each has occurring - Sum the binomial coefficients of the occurances (> 1)
Java Code
Lol I glossed over the first sentence and got mixed up with palindromes. I thought it was weird the explanation said
[ifa, fai]
was a valid pair but I just kept coding for palindromes like "wow hope that doesn't come back to haunt me" in my mental Kronk voice. I'll have to be more observant during interviews.My Python Solution