2847. Find Maximum Number of String Pairs
My accepted Python solution to LeetCode problem 2847, Find Maximum Number of String Pairs, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.3MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.3MB, accepted 2025-12-31.
class Solution:
def maximumNumberOfStringPairs(self, words: List[str]) -> int:
count = 0
seen = set()
for word in words:
if word[::-1] in seen:
count += 1
seen.add(word)
return count