JAVA SOLUTION || 100% FASTER || 1MS SOLUTION
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int maximumNumberOfStringPairs(String[] words) {\n        boolean[] flag = new boolean[words.length];\n\n        int ans = 0;\n\n        for(int i = 0; i < words.length - 1; i++) {\n            String word1 = words[i];\n\n            for(int j = i + 1; j < words.length; j++){\n                if(flag[j])\n                continue;\n\n                String word2 = words[j];\n\n                if(word1.charAt(0) == word2.charAt(1) && word1.charAt(1) == word2.charAt(0)){\n                    flag[i] = true;\n                    flag[j] = true;\n                    ans++;\n                }\n            }\n        }\n\n        return ans;\n    }\n}\n```
['Java']