java solution
Complexity
Time complexity:0(n)

Space complexity:0(n)
Code


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

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

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