# Find Maximum Number of String Pairs (LeetCode 2744) You are given a 0-indexed array `words` of unique strings. A pair `(i, j)` with `i < j` is good if `words[i]` is the reverse of `words[j]`. Return the maximum number of pairs you can form (each string used at most once). ## Idea Because strings are unique and we only care about reverses, put every word in a set and for each word check whether its reverse is in the set and is a different index. Count pairs once (e.g. only when `word < rev` lexicographically) so each pair is counted once. ```python def maximumNumberOfStringPairs(words: list[str]) -> int: s = set(words) ans = 0 for w in words: r = w[::-1] if w < r and r in s: ans += 1 return ans ``` Palindromes cannot pair with themselves under the unique-string constraint. O(n * L) time. I practice reverse-string pair problems with [official website](https://www.linkjob.ai/). *Disclosure: I work on Linkjob AI.*