Optimized simple solution - beats 100%🔥
Complexity
Time complexity: O(N)

Space complexity: O(N)
Code
# Complexity
- Time complexity: O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public boolean hasSameDigits(String s) {
        int[] digits = new int[s.length()];
        int distance = s.length();
        for (int i = 0; i < distance; i++) digits[i] = s.charAt(i) - '0';
        while (distance > 2) {
            int temp = (distance--) - 1;
            for (int i = 0; i < temp; i++) digits[i] = (digits[i] + digits[i + 1]) % 10;
        }
        return digits[0] == digits[1];
    }
}
```
['Java']