Java || Simple Solution ✅ || Rutime - 100% 💥 || Memory - 94% 💥 || With Explanation ✅
Approach\n\n1. Initialize two variables: n to store the length of the words array and cnt to keep track of the count of valid pairs.\n2. Use nested loops to ite
# Approach\n\n1. Initialize two variables: `n` to store the length of the `words` array and `cnt` to keep track of the count of valid pairs.\n2. Use nested loops to iterate over all possible pairs of strings in the `words` array. The outer loop variable `i` represents the index of the first word, and the inner loop variable `j` represents the index of the second word.\n3. Inside the nested loops, check if the first character of `words[i]` is equal to the second character of `words[j]`, and the second character of `words[i]` is equal to the first character of `words[j]`. This condition ensures that the two words can be paired according to the given conditions.\n4. If the condition is satisfied, increment the `cnt` variable by 1.\n5. After the loops finish executing, return the final value of `cnt` as the maximum number of pairs that can be formed.\n\n\n# Complexity\n- Time complexity: $$O(n^2)$$\n\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\n    public int maximumNumberOfStringPairs(String[] words) {\n        int n = words.length;\n        int cnt = 0;\n\n        for(int i = 0; i < n; i++)\n            for(int j = i + 1; j < n; j++)\n                if(words[i].charAt(0) == words[j].charAt(1) && words[i].charAt(1) == words[j].charAt(0))\n                        cnt++;\n                        \n        return cnt;\n    }\n}\n```
['Array', 'String', 'Simulation', 'Java', 'C#']