mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-08-03 02:47:26 +08:00
17 lines
292 B
Go
17 lines
292 B
Go
package leetcode
|
|
|
|
func modifyString(s string) string {
|
|
res := []byte(s)
|
|
for i, ch := range res {
|
|
if ch == '?' {
|
|
for b := byte('a'); b <= 'z'; b++ {
|
|
if !(i > 0 && res[i-1] == b || i < len(res)-1 && res[i+1] == b) {
|
|
res[i] = b
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return string(res)
|
|
}
|