Simple java code 1 ms beats 100 % && 41 mb beats 89.25 %
\n# Complexity\n- \n\n# Code\n\nclass Solution {\n    public int maximumNumberOfStringPairs(String[] words) {\n        int n = words.length;\n        int count 
\n# Complexity\n- \n![image.png](https://assets.leetcode.com/users/images/779370d1-dcda-4e8d-b4d9-99e60ad5c61c_1705984027.4342566.png)\n# Code\n```\nclass Solution {\n    public int maximumNumberOfStringPairs(String[] words) {\n        int n = words.length;\n        int count = 0;\n        for (int i = 0; i < n; i++) {\n            boolean flag = false;\n            for (int j = i + 1; j < n; j++) {\n                if (check(words[i], words[j])) {\n                    flag = true;\n                    break;\n                }\n            }\n            if (flag) {\n                count++;\n            }\n        }\n        return count;\n    }\n\n    private boolean check(String s, String s2) {\n        if(s.charAt(0)==s2.charAt(1)&&s.charAt(1)==s2.charAt(0))\n            return true;\n        return false;\n    }\n}\n```
['Array', 'String', 'Simulation', 'Java']