Easy, Simple and Fastest way in C++
Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n    string modifyString(string s) {\n        int len =
# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    string modifyString(string s) {\n        int len = s.size();\n        for(int i=0; i<s.size(); i++) {\n            char c1, c2;\n            if(s[i] == \'?\') {\n                if(i-1>=0 && i+1<len) {\n                    c1=s[i-1];\n                    c2=s[i+1];\n                }\n                else if(i-1>=0) {\n                    c1=c2=s[i-1];\n                }\n                else {\n                    c1=c2=s[i+1];\n                }\n                \n                for(char ch=\'a\'; ch<=\'z\'; ch++) {\n                    if(ch!=c1 && ch!=c2) {\n                        s[i] = ch;\n                        break;\n                    }\n                }\n            }\n        }\n\n        return s;\n    }\n};\n```
['C++']