Short simple python solution


  • 0

    Nothing fancy. It is very simple, normal and it works!

    class Solution(object):
        def generatePossibleNextMoves(self, s):
            result = []
            for i in range(len(s)-1):
                if s[i:i+2] == "++":
                    state = s[:i] + "--"
                    if i+2 < len(s):
                        state += s[i+2:]
                    result.append(state)
            return result
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.