Skip to content

Commit 10422e1

Browse files
committed
2021-03-11
1 parent 477c317 commit 10422e1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution(object):
2+
def modifyString(self, s):
3+
"""
4+
:type s: str
5+
:rtype: str
6+
"""
7+
res = []
8+
for i, ch in enumerate(s):
9+
if ch == "?":
10+
for new in "abc":
11+
if ((i and res[-1] != new) or not i) and ((i < len(s) - 1 and s[i + 1] != new) or i == len(s) - 1):
12+
res.append(new)
13+
break
14+
else:
15+
res.append(ch)
16+
17+
return "".join(res)

0 commit comments

Comments
 (0)