3768. Check If Digits Are Equal in String After Operations I
My accepted Python solution to LeetCode problem 3768, Check If Digits Are Equal in String After Operations I, running in 21ms.
- Difficulty: Easy
- Python
- Runtime 21ms
- Memory 17.2MB
- 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 21ms, memory 17.2MB, accepted 2025-12-30.
class Solution:
def hasSameDigits(self, s: str) -> bool:
d = [int(c) for c in s]
while len(d) > 2:
d = [(d[i] + d[i+1]) % 10 for i in range(len(d)-1)]
return d[0] == d[1]