Golang | Bitmask | TC O(n*m), SC O(n)
Complexity\n- Time complexity: O(n*m)\n- Space complexity: O(n)\n> n - words.length, m - word.length\n\n# Code\n\nfunc similarPairs(words []string) (result int)
# Complexity\n- Time complexity: O(n*m)\n- Space complexity: O(n)\n> n - words.length, m - word.length\n\n# Code\n```\nfunc similarPairs(words []string) (result int) {\n\tcounter := make(map[int]int)\n\tfor i := 0; i < len(words); i++ {\n\t\tcounter[toMask(words[i])]++\n\t}\n\n\tfor _, x := range counter {\n\t\tresult += (x - 1) * x / 2\n\t}\n\n\treturn result\n}\n\nfunc toMask(s string) (result int) {\n\tfor i := 0; i < len(s); i++ {\n\t\tresult |= 1 << (s[i] - \'a\')\n\t}\n\n\treturn result\n}\n```
['Go']