Repeated Digit Sum Check || String Comparison || Beats 100.00%
IntuitionThe problem asks to determine if after repeatedly summing adjacent digits modulo 10, the final two digits are the same. This suggests a simulation appr
# Intuition
The problem asks to determine if after repeatedly summing adjacent digits modulo 10, the final two digits are the same. This suggests a simulation approach where we perform the summing operation until we are left with a string of length 2, and then check if the two digits are equal.

# Approach
1.  Iterate while the length of the string `s` is greater than 2.
2.  In each iteration, create a new string by summing adjacent digits modulo 10.
3.  Replace the original string `s` with the new string.
4.  After the loop finishes, check if the first and second characters of the remaining string are equal.
5.  Return `true` if they are equal, `false` otherwise.

# Complexity
-   Time complexity: $$O(n^2)$$
    -   In the worst case, the loop runs `n-2` times, and each iteration takes `O(n)` time to create the new string.
-   Space complexity: $$O(n)$$
    -   In each iteration, we create a new string of length `n-1`, which takes `O(n)` space.

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

['Java']