Tried a lot but only 749/776 passed :(
\nclass Solution {\npublic:\n    string modifyString(string s) {\n        string str="";\n        for(int i=0;i<s.size();i++){\n            if(s[i]==\'?\')\n   
```\nclass Solution {\npublic:\n    string modifyString(string s) {\n        string str="";\n        for(int i=0;i<s.size();i++){\n            if(s[i]==\'?\')\n            {\n                int x,y;\n                if(i==0){\n                  x= s[i+1];\n                    if(x<97 || x>122)\n                        {\n                            char c= 97;\n                    str+=c;\n                        }\n                    else if(x!=122){\n                        char c= x+1;\n                    str+=c;\n                    }\n                    else{\n                         char c= x-1;\n                    str+=c;\n                    }\n                    \n                    \n                }\n                else if(i== s.size()-1){\n                    y=s[i-1];\n                    if(y<97 || y>122)\n                        {\n                            char c= 98;\n                    str+=c;\n                        }\n                    else if(y!=122){\n                        char c= y+1;\n                    str+=c;\n                    }\n                    else{\n                         char c= y-1;\n                    str+=c;\n                    }\n                }\n                else{\n                    x=s[i+1];\n                    y=s[i-1]; \n                    if(x==y)\n                    {\n                        if(x<97 || x>122)\n                        {\n                            char c= 99;\n                    str+=c;\n                        }\n                        else if(x!=122){\n                        char c= x+1;\n                    str+=c;\n                    }\n                    else{\n                         char c= x-1;\n                    str+=c;\n                    }\n                    }\n                    \n                    else\n                    {\n                        if(x<97 || x>122)\n                        {\n                            char c= 100;\n                    str+=c;\n                        }\n                        else if(x!=122){\n                            x++;\n                            if(x==y ){\n                                x++;\n                            }\n                        char c= x;\n                    str+=c;\n                    }\n                    else{\n                         x--;\n                            if(x==y){\n                                x--;\n                            }\n                        char c= x;\n                    str+=c;\n                    }\n                    }\n                }\n            \n                \n            }\n            else{\n                str += s[i];\n                \n            }\n        }\n        return str;\n    }\n};\n```
[]