[Java] Bitmask and counting
Intuition\n Describe your first thoughts on how to solve this problem. \nFilter each char in word and compare to others.\n\n# Approach\n Describe your approach 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFilter each char in word and compare to others.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nConvert word to integer with bit mask, then use map to collect the count of each integer.\n\n# Complexity\n- Time complexity: $$O(M*N)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(N)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n  public int similarPairs(String[] words) {\n    Map<Integer, Integer> group = new HashMap<>();\n    for (String word : words) {\n      group.merge(convert(word), 1, Integer::sum);\n    }\n\n    int count = 0;\n    for (int value : group.values()) {\n      count += value * (value - 1) / 2;\n    }\n\n    return count;\n  }\n\n  private int convert(String word) {\n    int n = 0;\n    for (char c : word.toCharArray()) {\n      n |= 1 << (c - \'a\');\n    }\n\n    return n;\n  }\n}\n\n```
['Bit Manipulation', 'Counting', 'Java']