Java | My Easy To Understand Solution | Beginner Friendly
\nTC : O(n * n)\nSC : O(26) ~ O(1)\nclass Solution {\n    public int similarPairs(String[] words) {\n        int count = 0;\n        for(int i = 0; i < words.le
```\nTC : O(n * n)\nSC : O(26) ~ O(1)\nclass Solution {\n    public int similarPairs(String[] words) {\n        int count = 0;\n        for(int i = 0; i < words.length; ++i){\n            String word1 = words[i];\n            int[] f1 = new int[26]; //frequency array 1\n            \n            for(int a = 0; a < word1.length(); ++a){ //making frequency array for word1\n                char ch = word1.charAt(a);\n                f1[ch - \'a\']++;\n            }\n            \n            for(int j = i + 1; j < words.length; ++j){\n                String word2 = words[j];\n                int[] f2 = new int[26]; //frequency array 2\n    \n                for(int b = 0; b < word2.length(); ++b){ //making frequency array for word2\n                    char ch = word2.charAt(b);\n                    f2[ch - \'a\']++;\n                }\n                \n                boolean flag = true;\n                for(int k = 0; k < 26; ++k){\n                    if((f1[k] > 0 && f2[k] == 0) || (f1[k] == 0 && f2[k] > 0)){\n                        flag = false;\n                        break;\n                    }\n                }\n                \n                if(flag) count++;\n            }\n        }\n        \n        return count;\n    }\n}\n```
['Array', 'Java']