Brute Force C++
Intuition\nBrute force comparing all pairs of strings\n\n# Code\n\nclass Solution {\npublic:\n    bool func(string &word1, string &word2)\n    {\n        vector
# Intuition\nBrute force comparing all pairs of strings\n\n# Code\n```\nclass Solution {\npublic:\n    bool func(string &word1, string &word2)\n    {\n        vector<int>v(26, 0);\n        for(int i=0;i<word1.size();i++)\n        {\n           v[word1[i]- \'a\']++;\n        }\n        for(int i=0;i<word2.size();i++)\n        {\n            int x = v[word2[i]-\'a\'];\n            if(x == 0) return false;\n        }\n        return true;\n    }\n    int similarPairs(vector<string>& words) {\n        sort(words.begin(), words.end());\n        for(auto &i:words)\n        {\n            sort(i.begin(), i.end());\n        }\n        int n = words.size();\n        int cnt = 0;\n        for(int i=0;i<n;i++)\n        {\n            for(int j = i+1;j<n;j++)\n               { \n                if(func(words[i], words[j]) and func(words[j], words[i]))\n                    cnt++;\n               }\n        }\n        return cnt;\n    }\n};\n```
['C++']