Replace All ?'s to Avoid Consecutive Repeating Characters Solution Java
class Solution {\n    public String modifyString(String s) {\n        char[] array = s.toCharArray();\n        int length = array.length;\n        if (array[0] 
class Solution {\n    public String modifyString(String s) {\n        char[] array = s.toCharArray();\n        int length = array.length;\n        if (array[0] == \'?\') {\n            if (length == 1)\n                array[0] = \'a\';\n            else {\n                if (array[1] == \'a\')\n                    array[0] = \'b\';\n                else\n                    array[0] = \'a\';\n            }\n        }\n        if (array[length - 1] == \'?\') {\n            if (array[length - 2] == \'a\')\n                array[length - 1] = \'b\';\n            else\n                array[length - 1] = \'a\';\n        }\n        for (int i = 1; i < length - 1; i++) {\n            char curr = array[i];\n            if (curr == \'?\') {\n                char prev = array[i - 1], next = array[i + 1];\n                char letter = \'a\';\n                while (letter == prev || letter == next)\n                    letter++;\n                array[i] = letter;\n            }\n        }\n        return new String(array);\n    }\n}
['String']