Golang 4 ms 4.1 MB
Complexity\n- Time complexity: O(n)\n- Space complexity: O(n)\n# Code\n\nfunc similarPairs(words []string) int {\n\tresult := 0\n\th := make(map[int32]byte)\n\t
# Complexity\n- Time complexity: $$O(n)$$\n- Space complexity: $$O(n)$$\n# Code\n```\nfunc similarPairs(words []string) int {\n\tresult := 0\n\th := make(map[int32]byte)\n\tfor _, word := range words {\n\t\tvar chars int32\n\t\tfor i := 0; i < len(word); i++ {\n\t\t\tchars |= 1 << (word[i] - \'a\')\n\t\t}\n\t\tc := h[chars]\n\t\tresult += int(c)\n\t\th[chars] = c + 1\n\t}\n\treturn result\n}\n```
['Go']