293 Flip Game
293. Flip Game
题目: https://leetcode.com/problems/flip-game/
难度:
Easy
思路
class Solution(object):
def generatePossibleNextMoves(self, s):
"""
:type s: str
:rtype: List[str]
"""
res = []
if not s or len(s) <= 1:
return res
for i in range(len(s)-1):
if s[i] == '+' and s[i+1] == '+':
res.append(s[:i]+'--'+s[i+2:])
return res
这里要注意一个点:s[i+2:] 虽然i+2取不到,但是s[i+2:]就是一个空字符串。