Weekly Contest 438 Q#1
IntuitionThe intuition behind this approach is straightforward—we can directly follow the given instructions to arrive at the optimal solution.Approach
Perform
# Intuition
The intuition behind this approach is straightforward—we can directly follow the given instructions to arrive at the optimal solution.

# Approach
1. Perform the given operations iteratively, updating all elements up to `lenth - 1`.
2. After each iteration, the effective length of the array decreases by one.
2. Repeat step #1 until only two characters remain.

# Complexity
- Time complexity:
* The overall time complexity of this solution is `Quadratic`  

- Space complexity:
* The overall space complexity of this solution is `Constant` 

# Code
```java []
class Solution {
    public boolean hasSameDigits(String s) {
        char[] digits = s.toCharArray();
            int length = digits.length;

            while (length > 2) {
                for (int i = 0; i < length - 1; i++) {
                    digits[i] = (char) ((digits[i] + digits[i + 1] - 96) % 10 + 48);
                }
                length--;
            }

            return digits[0] == digits[1];
    }
}
```
['Java']