Swift Character Set Frequency, then (N * (N-1)) / 2
Intuition\n Describe your first thoughts on how to solve this problem. \nCharacter Set Frequency\ncombination formulat: (N * (N-1)) / 2\n(pair [1, 2] and [2, 1]
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nCharacter Set Frequency\ncombination formulat: (N * (N-1)) / 2\n(pair [1, 2] and [2, 1] are the same)\n\n# Code\n```\nclass Solution {\n    func similarPairs(_ words: [String]) -> Int {\n        var charSetFrequency = [Set<Character>: Int]()\n        for word in words {\n            charSetFrequency[countCharSet(word), default: 0] += 1\n        }\n        var pair = 0\n        charSetFrequency.values\n            .filter { $0 > 1 }\n            .forEach {\n                pair += ($0 * ($0-1)) / 2\n            }\n        return pair\n    }\n    \n    func countCharSet(_ word: String) -> Set<Character> {\n        var charSet = Set<Character>()\n        word.forEach {\n            charSet.insert($0)\n        }\n        return charSet\n    }\n}\n```
['Swift']