Easy logic and code
Intuitionchanging the string based on its size that should not get to 2.ApproachIterative Digit ReductionComplexity

Time complexity:
O(n).


Space complexity:
# Intuition
changing the string based on its size that should not get to 2.

# Approach
Iterative Digit Reduction

# Complexity
- Time complexity:
O(n).

- Space complexity:
O(1).

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