Best and simple java approach
Code\njava []\nclass Solution {\n    public int maximumNumberOfStringPairs(String[] words) {\n        int ans=0;\n        for(int i=0;i<words.length;i++) {\n   
# Code\n```java []\nclass Solution {\n    public int maximumNumberOfStringPairs(String[] words) {\n        int ans=0;\n        for(int i=0;i<words.length;i++) {\n        \tfor(int j=i+1;j<words.length;j++) {\n        \t\tif(words[i].charAt(0)==words[j].charAt(1) && words[i].charAt(1)==words[j].charAt(0)) \n        \t\t\tans++;\n        \t}\n        }\n        return ans;\n    }\n}\n```
['Java']