LeetCode solutions

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

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 21ms, memory 17.2MB, accepted 2025-12-30.

python
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]

Source