Iterative Modulo Reduction for Equal Digits Check
IntuitionThe problem requires repeatedly applying an operation to a string of digits until only two digits remain. The operation involves replacing each pair of
# Intuition
The problem requires repeatedly applying an operation to a string of digits until only two digits remain. The operation involves replacing each pair of consecutive digits with their sum modulo 10. The goal is to determine if the final two digits are the same.

# Approach
1. Iterative Reduction: Continuously apply the operation to the string until its length is reduced to two. Each iteration processes consecutive pairs of digits, replacing them with their sum modulo 10.
2. Check Final Digits: Once the string has exactly two digits, check if both digits are identical.

# Complexity
- Time complexity: $$O(n²)$$, where n is the initial length of the string. Each operation reduces the string length by 1, and each operation processes O(k) elements where k decreases from n to 3.

- Space complexity: $$O(n)$$, as each operation generates a new string of length one less than the previous.

# Code
```cpp []
class Solution {
public:
    bool hasSameDigits(string s) {
        while (s.size()>2){
            string k="";
            for (int i=0;i<s.size()-1;i++){k+=((s[i]-'0'+s[i+1]-'0')%10+'0');}
            s=k;
        }
        return s[0]==s[1];
    }
};
```
['C++']