2025-08-21 13:38:20 +0000 UTC

Find Maximum Number of String Pairs

Code

class Solution:
    def maximumNumberOfStringPairs(self, words: List[str]) -> int:
        enc = set()
        res = 0
        for word in words:
            if word in enc:
                res += 1
            else:
                enc.add(word[::-1])
        return res