I have a lot of strings, and I need to check how many pairs contain the same characters.
Currently, my strategy is to create an int[128] chars, and for each character in the string, to increment the count in chars. So, at the end, chars would be a 128-sized array, with each index mapping to a character number, and the value its count.
I'd then hash chars, say by using Java's Arrays.hashCode() function.
Is there a more efficient way to approach this? I tried XOR-ing each character in the string in the first loop (together with building chars), which works (but is terribly slow on my assignment test cases; I suspect they are designed to defeat a simple XOR hash function). Are there any efficient hash functions that work?