Java solution faster than 100%
We dont want consecutive characters and multiple solutions are possible, so all we need to check is whether the character we replace is not the same as its left
We dont want consecutive characters and multiple solutions are possible, so all we need to check is whether the character we replace is not the same as its left/right neighbor.\nWe can simply solve this problem by checking with 3 alphabets : \'a\', \'b\' and \'c\'\nIf left is null, check 2nd character\nelse if right is null, check second last character\nelse just check left and right\n\n```class Solution {\n    public String modifyString(String s) {\n        \n        if(s.length() == 1)\n            return (s.equals("?")) ? "a" : s;\n        char[] strArr = s.toCharArray();\n        \n        for(int i = 0; i < strArr.length; i++) {\n            char c = strArr[i];\n            if(c == \'?\') {\n                if(i == 0 ){\n                    strArr[i] = (strArr[i+1] == \'a\') ? \'b\' : \'a\';\n                } else if(i == strArr.length - 1){\n                    strArr[i] = (strArr[i-1] == \'a\') ? \'b\' : \'a\';\n                } else {\n                    for(char temp = \'a\' ; temp <= \'c\';) {\n                        if(strArr[i-1] == temp || strArr[i+1] == temp) {\n                            temp++;\n                        } else {\n                            strArr[i] = temp;\n                            break;\n                        }\n                    }\n                }  \n            }\n        }\n        return String.valueOf(strArr);\n    }\n    \n    \n}```
[]