package leetcode;

/**
 * https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters/
 */
public class Problem1576 {
    public String modifyString(String s) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1576 prob = new Problem1576();
        System.out.println(prob.modifyString("?zs")); // "azs"
        System.out.println(prob.modifyString("ubv?w")); // "ubvaw"
        System.out.println(prob.modifyString("j?qg??b")); // "jaqgacb"
        System.out.println(prob.modifyString("??yw?ipkj?")); // "acywaipkja"
    }
}

@@ -192,412 +192,798 @@
     
-// TODO%0A        return null;
+String answer = %22%22;%0A        for (int i = 0; i %3C s.length(); i++) %7B
 %0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1576 prob = new Problem1576();%0A        System.out.println(prob.modifyString(%22?zs%22)); // %22azs%22%0A        System.out.println(prob.modifyString(%22ubv?w%22)); // %22ubvaw%22%0A        System.out.println(prob.modifyString(%22j?qg??b%22)); // %22jaqgacb%22%0A        System.out.println(prob.modifyString(%22??yw?ipkj?%22)); // %22acywaipkja%22
+    if (s.charAt(i) == '?') %7B%0A                for (char c = 'a'; c %3C= 'z'; c++) %7B%0A                    if (i - 1 %3E= 0) %7B%0A                        char prev = answer.charAt(i - 1);%0A                        if (prev == c) %7B%0A                            continue;%0A                        %7D%0A                    %7D%0A                    if (i + 1 %3C s.length()) %7B%0A                        char next = s.charAt(i + 1);%0A                        if (next == c) %7B%0A                            continue;%0A                        %7D%0A                    %7D%0A                    answer += c;%0A                    break;%0A                %7D%0A            %7D else %7B%0A                answer += s.charAt(i);%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1576