C++ | Using Vector of Vector of 26 Size |
Time Complexity: O(N * N)\nSpace Complexity: O(N * 26)\nInstead of using maps or sets, I thought of using a double dimensional array or vector of vector, and th
**Time Complexity: O(N * N)\nSpace Complexity: O(N * 26)**\nInstead of using maps or sets, I thought of using a double dimensional array or vector of vector, and then I just checked if the vectors are equal or not!\n```\nclass Solution {\npublic:\n    int similarPairs(vector<string>& words) {\n        vector<vector<int>> v;\n        for(auto i:words){\n            vector<int> ch(26,0);\n            string t="";\n            for(auto j:i){\n                if(ch[j-\'a\']==0)\n                ch[j-\'a\']++;\n            }\n            v.push_back(ch);\n        }\n        int ans=0;\n        for(int i=0;i<words.size();i++){\n            for(int j=i+1;j<words.size();j++){\n                if(v[i]==v[j]) ++ans;\n            }\n        }\n        return ans;\n    }\n};\n```
['C']