3461. Check If Digits Are Equal in String After Operations I - || Easy Python || List || String ||
IntuitionThe goal is to iteratively transform the input string by summing adjacent digits and taking the last digit of the sum (modulo 10). This process continu
# Intuition
The goal is to iteratively transform the input string by summing adjacent digits and taking the last digit of the sum (modulo 10). This process continues until only two digits remain. If the resulting two digits are the same, return True; otherwise, return False.
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
1. Initialize a list (res) containing the input string s.
2. Iterate while res[0] has more than two characters:
    - Generate a new string where each digit is obtained by summing adjacent digits modulo 10.
    - Replace res[0] with this new transformed string.
3. Check the final two-digit result:
    - If both digits are the same, return True; otherwise, return False.
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
    - Each iteration reduces the length of the string by 1, so it runs approximately O(n) times.
    - Within each iteration, constructing the new string takes O(n), leading to an overall complexity of O(n^2 ).
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: 
    - The algorithm maintains a list (res) storing intermediate results, with a maximum size of O(n).
    - The space complexity is O(n).
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def hasSameDigits(self, s: str) -> bool:
        res = []
        res.append(s)
        while len(res[0])!=2:
            temp = ''
            for i in range(len(res[0])-1):
                temp +=str((int(res[0][i])+int(res[0][i+1]))%10)
            res.pop()
            res.append(temp)
        return res[0][0]==res[0][1]


```
['Python3']