3736. Find Valid Pair of Adjacent Digits in String
My accepted Python solution to LeetCode problem 3736, Find Valid Pair of Adjacent Digits in String, running in 7ms.
- Difficulty: Easy
- Python
- Runtime 7ms
- Memory 17.4MB
- 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 7ms, memory 17.4MB, accepted 2026-01-01.
class Solution:
def findValidPair(self, s: str) -> str:
from collections import Counter
freq = Counter(s)
for i in range(len(s) - 1):
a, b = s[i], s[i + 1]
if a != b and freq[a] == int(a) and freq[b] == int(b):
return a + b
return ""