Skip to content

Commit

Permalink
2019-09-11
Browse files Browse the repository at this point in the history
  • Loading branch information
JiayangWu committed Sep 12, 2019
1 parent 483497f commit 8b82426
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 0294.翻转游戏II/0294-翻转游戏II.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution(object):
def canWin(self, string):
"""
:type s: str
:rtype: bool
"""
record = {}
def helper(s):
if s in record:
return record[s]
for i in range(len(s) - 1):
if s[i:i + 2] == "++":
next_s = s[:i] + "--" + s[i + 2:]
if not helper(next_s):
record[next_s] = False
return True
return False # ++²»´æÔÚ

return helper(string)

0 comments on commit 8b82426

Please sign in to comment.