C++/Python O(n)
We do not need more than 3 letters to build a non-repeating character sequence.\n\nFor Python, we can use set difference to determine which one to use.\n\nPytho
We do not need more than 3 letters to build a non-repeating character sequence.\n\nFor Python, we can use set difference to determine which one to use.\n\n**Python**\n```python\ndef modifyString(self, s: str) -> str:\n\tres, prev = "", \'?\'\n\tfor i, c in enumerate(s):\n\t\tnext = s[i + 1] if i + 1 < len(s) else \'?\'\n\t\tprev = c if c != \'?\' else {\'a\', \'b\', \'c\'}.difference({prev, next}).pop()\n\t\tres += prev\n\treturn res\n```\n\n**C++**\n```cpp\nstring modifyString(string s) {\n    for (auto i = 0; i < s.size(); ++i)\n        if (s[i] == \'?\')\n            for (s[i] = \'a\'; s[i] <= \'c\'; ++s[i])\n                if ((i == 0 || s[i - 1] != s[i]) && (i == s.size() - 1 || s[i + 1] != s[i]))\n                    break;\n    return s;\n}\n```
[]