simplest solution | c++
IntuitionThe problem involves repeatedly reducing a string by summing consecutive digits and taking only the last digit (mod 10). The process continues until th
# Intuition
The problem involves repeatedly reducing a string by summing consecutive digits and taking only the last digit (mod 10). The process continues until the string is reduced to two characters, at which point we check if they are equal.

# Approach
1. Start with a given numeric string s.
2. Continuously reduce the string:
3. Compute a new string where each character is the last digit of the sum of adjacent characters.
4. Repeat until only two characters remain.
5. Check if the two remaining characters are equal.


# Complexity
- Time complexity:
$$O(n^2)$$

- Space complexity:
$$O(n)$$

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