java.lang.Object
g1501_1600.s1576_replace_all_s_to_avoid_consecutive_repeating_characters.Solution

public class Solution extends Object
1576 - Replace All ?&rsquo;<p>s to Avoid Consecutive Repeating Characters.</p> <p>Easy</p> <p>Given a string <code>s</code> containing only lowercase English letters and the <code>'?'</code> character, convert <strong>all</strong> the <code>'?'</code> characters into lowercase letters such that the final string does not contain any <strong>consecutive repeating</strong> characters. You <strong>cannot</strong> modify the non <code>'?'</code> characters.</p> <p>It is <strong>guaranteed</strong> that there are no consecutive repeating characters in the given string <strong>except</strong> for <code>'?'</code>.</p> <p>Return <em>the final string after all the conversions (possibly zero) have been made</em>. If there is more than one solution, return <strong>any of them</strong>. It can be shown that an answer is always possible with the given constraints.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;?zs&rdquo;</p> <p><strong>Output:</strong> &ldquo;azs&rdquo;</p> <p><strong>Explanation:</strong> There are 25 solutions for this problem. From &ldquo;azs&rdquo; to &ldquo;yzs&rdquo;, all are valid. Only &ldquo;z&rdquo; is an invalid modification as the string will consist of consecutive repeating characters in &ldquo;zzs&rdquo;.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;ubv?w&rdquo;</p> <p><strong>Output:</strong> &ldquo;ubvaw&rdquo;</p> <p><strong>Explanation:</strong> There are 24 solutions for this problem. Only &ldquo;v&rdquo; and &ldquo;w&rdquo; are invalid modifications as the strings will consist of consecutive repeating characters in &ldquo;ubvvw&rdquo; and &ldquo;ubvww&rdquo;.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 100</code></li> <li><code>s</code> consist of lowercase English letters and <code>'?'</code>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details