template have been erased and replaced with ?. The other characters are lowercase English letters, and no two adjacent letters among them are equal.
Replace every ? with a lowercase English letter so that no two neighbouring characters of the result are the same. Letters already in place must not change.
There are usually many ways to do this; return the lexicographically smallest one. A valid filling always exists.template='?a?' → 'bab'
The first gap cannot be "a" because its right neighbour is "a", so the smallest fit is "b"; the same goes for the last gap.
template='c??b' → 'cacb'
After "c" we put "a"; the next gap sits between "a" and "b", so it gets "c".
template='???' → 'aba'
With nothing fixed at the edges, the smallest option is "aba".
template.length ≤ 100template consists of lowercase English letters and ?template has no two equal adjacent letterstemplate='?a?'
'bab'
Run checks the first 3 tests in your browser. Submit checks all 120 tests on the server, hidden ones included.