Posted on

Description

Submission

class Solution {
public:
    string modifyString(string s) {
        for(int i = 0; i < s.length(); ++i) {
            if(s[i] != '?') continue;
            for(int j = 0; j < 26; ++j) {
                char ch = j + 'a';
                if(i > 0 && s[i-1] == ch) continue;
                if(s[i+1] == ch) continue;
                s[i] = ch;
                break;
            }
        }

        return s;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *