JAVA | HashSet
Solution:\n\nclass Solution {\n    public int maximumNumberOfStringPairs(String[] words) {\n        Set<String> set = new HashSet<>();\n        int cnt = 0;\n  
# Solution:\n```\nclass Solution {\n    public int maximumNumberOfStringPairs(String[] words) {\n        Set<String> set = new HashSet<>();\n        int cnt = 0;\n        for (String s : words) {\n            StringBuilder sb = new StringBuilder(s).reverse();\n            if (set.contains(sb.toString())) {\n                cnt++;\n            } else {\n                set.add(s);\n            }\n        }\n        return cnt;\n    }\n}\n```\n### Time complexity: $$O(n^2)$$\n> Worst case time complexity for lookup in hashset can be $$O(n)$$.\n### Space complexity: $$O(n)$$
['Array', 'Hash Table', 'String', 'Java']