Leetcode Daily: 3461. Check If Digits Are Equal in String After Operations I
Usually check out the leetcode daily problem every once in a while.
I do chase the feeling when I solve a hard problem, but the problem this time seems pretty straightforward.
Here is my solution, I think I could make it more optimized with some python built-in functions.
class Solution:
def hasSameDigits(self, s: str) -> bool:
while len(s) > 2:
c = ""
for i in range(len(s) -1):
x, y = ord(s[i]) - ord('0'), ord(s[i+1]) - ord('0')
c += str((x + y) % 10)
s = c
return s[0] == s[1