Skip to content

Commit 8b82426

Browse files
committed
2019-09-11
1 parent 483497f commit 8b82426

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution(object):
2+
def canWin(self, string):
3+
"""
4+
:type s: str
5+
:rtype: bool
6+
"""
7+
record = {}
8+
def helper(s):
9+
if s in record:
10+
return record[s]
11+
for i in range(len(s) - 1):
12+
if s[i:i + 2] == "++":
13+
next_s = s[:i] + "--" + s[i + 2:]
14+
if not helper(next_s):
15+
record[next_s] = False
16+
return True
17+
return False # ++²»´æÔÚ
18+
19+
return helper(string)

0 commit comments

Comments
 (0)