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.
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)
Sherlock and Anagrams
You are viewing a single comment's thread. Return to all comments →
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)