Simple C++ Solution | Weekly Contest 438 | String
SolutionComplexity

Time complexity:
O(n2)


Space complexity:
O(n)

Code
# Solution

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

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

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