✅ One Line Solution
Code #1\nTime complexity: O(n). Space complexity: O(n).\n\nclass Solution:\n    def maximumNumberOfStringPairs(self, w: List[str]) -> int:\n        return len(w
# Code #1\nTime complexity: $$O(n)$$. Space complexity: $$O(n)$$.\n```\nclass Solution:\n    def maximumNumberOfStringPairs(self, w: List[str]) -> int:\n        return len(w)-len({*map(frozenset,w)})\n```\n\n# Code #2\nTime complexity: $$O(n)$$. Space complexity: $$O(n)$$.\n```\nclass Solution:\n    def maximumNumberOfStringPairs(self, w: List[str]) -> int:\n        return len(w)-len({min(v)+max(v) for v in w})\n```\n\n# Code #3\nTime complexity: $$O(n)$$. Space complexity: $$O(n)$$.\n```\nclass Solution:\n    def maximumNumberOfStringPairs(self, w: List[str]) -> int:\n        return len({*w}&{v[::-1] for v in w if v!=v[::-1]})//2\n```\n\n# Code #4\nTime complexity: $$O(n^2)$$. Space complexity: $$O(1)$$.\n```\nclass Solution:\n    def maximumNumberOfStringPairs(self, w: List[str]) -> int:\n        return sum(v[::-1] in w[i+1:] for i,v in enumerate(w))\n```
['Array', 'Hash Table', 'String', 'Simulation', 'Python', 'Python3']