simple and easy C++ solution 😍❤️‍🔥
if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code\n\nclass Solution {\npublic:\n    bool isValidIndex(int i, int n)\n    {\n        return (i >= 0 
# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code\n```\nclass Solution {\npublic:\n    bool isValidIndex(int i, int n)\n    {\n        return (i >= 0 and i < n);\n    }\n    string modifyString(string s) \n    {\n        int n = s.size();\n        if(n == 1 and s[0] == \'?\') return "a";\n        for(int i=0;i<n;i++)\n        {\n            if(s[i] == \'?\')\n            {\n                if(isValidIndex(i+1, n) and isValidIndex(i-1, n))\n                {\n                    for(char ch=\'a\';ch<=\'z\';ch++)\n                    {\n                        if(s[i-1] != ch and s[i+1] != ch)\n                        {\n                            s[i] = ch;\n                            break;\n                        }\n                    }\n                }\n                else if(!isValidIndex(i+1, n) and isValidIndex(i-1, n))\n                {\n                    for(char ch=\'a\';ch<=\'z\';ch++)\n                    {\n                        if(s[i-1] != ch)\n                        {\n                            s[i] = ch;\n                            break;\n                        }\n                    }\n                }\n                else if(isValidIndex(i+1, n) and !isValidIndex(i-1, n))\n                {\n                    for(char ch=\'a\';ch<=\'z\';ch++)\n                    {\n                        if(s[i+1] != ch)\n                        {\n                            s[i] = ch;\n                            break;\n                        }\n                    }\n                }\n            }\n        } \n        return s;\n    }\n};\n```
['String', 'Simulation', 'C++']