Simple C++ Solution using queue.
Complexity

Time complexity:
O(n)


Space complexity:
O(n)

Code
# Complexity
- Time complexity:
$$O(n)$$

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

# Code
```cpp []
class Solution {
public:
    bool hasSameDigits(string s) {
        deque<int> q;
        for (char c : s) {
            q.push_back(c - '0');
        }
        int n = 0;
        int c = q.size();
        while (q.size() > 2) {
            if (--c) {
                n = q.front();
                q.pop_front();
                q.push_back((n + q.front()) % 10);
            } else {
                q.pop_front();
                c = q.size();
            }
        }
        return q.front() == q.back();
    }
};
```
['C++']