Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 10422e1

Browse files
2021年03月11日
1 parent 477c317 commit 10422e1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /