Java Simple O(n) loop
for each char, just try \u2018a\u2019, \u2018b\u2019, \u2018c\u2019, and select the one not the same as neighbors.\n\n\n    public String modifyString(String s)
for each char, just try \u2018a\u2019, \u2018b\u2019, \u2018c\u2019, and select the one not the same as neighbors.\n\n```\n    public String modifyString(String s) {\n        char[] arr = s.toCharArray();\n        for (int i = 0; i < arr.length; i++) {\n            if (arr[i] == \'?\') {\n                for (int j = 0; j < 3; j++) {\n                    if (i > 0 && arr[i - 1] - \'a\' == j) continue;\n                    if (i + 1 < arr.length && arr[i + 1] - \'a\' == j) continue;\n                    arr[i] = (char) (\'a\' + j);\n                    break;\n                }\n            }\n        }\n        return String.valueOf(arr);\n    }\n```\n
[]