Simple Java Solution using HashSet/Array
1. Using hashset (Slow 73ms)\n## Approach\n Describe your approach to solving the problem. \nWe are using a hashSet to store the characters of each string and u
# 1. Using hashset (Slow 73ms)\n## Approach\n<!-- Describe your approach to solving the problem. -->\nWe are using a hashSet to store the characters of each string and use equals() method to check if size of both the sets are equal and both contain the same elements.\n\n## Complexity\n- Time complexity: $$O(n*n*k)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n*k)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nn is the length of array and k is the number of unique characters of word in array\n\n## Code\n```Java []\nclass Solution {\n    public int similarPairs(String[] words) {\n        int res=0;\n        Set<Character> sets[] = new Set[words.length];\n        for(int i=0; i<words.length; ++i){\n            sets[i] = new HashSet<>();\n            for(char ch: words[i].toCharArray())    sets[i].add(ch);\n        }\n        for(int i=0; i<words.length; ++i){\n            for(int j=i+1; j<words.length; ++j){\n                if(sets[i].equals(sets[j]))    res+=1;\n            }\n        }\n        return res;\n    }\n}\n```\n\n# 2. Using array to mark visible (Fast 10ms)\n## Approach\n<!-- Describe your approach to solving the problem. -->\nWe are using a Boolean Arrays to mark the presence of characters of each string and use Arrays equals() method to check if both arrays contain the same elements.\n\n## Complexity\n- Time complexity: $$O(n*n*26)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n*26)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nn is the length of array\n\n## Code\n```Java []\nclass Solution {\n    boolean[][] arr;\n    public int similarPairs(String[] words) {\n        int res=0;\n        arr = new boolean[words.length][26];\n        for(int i=0; i<words.length; ++i){\n            for(char ch: words[i].toCharArray())    arr[i][ch-\'a\']=true;\n        }\n        for(int i=0; i<words.length; ++i){\n            for(int j=i+1; j<words.length; ++j){\n                if(Arrays.equals(arr[i],arr[j]))    res+=1;\n            }\n        }\n        return res;\n    }\n}\n```
['Array', 'Hash Table', 'Java']