Easy to understand python solution


  • 0
    A
    def generatePossibleNextMoves(self, s):
        """
        :type s: str
        :rtype: List[str]
        """
        result = []
        for i in range(len(s)-1):
            if s[i] == "+" and s[i+1] == "+":
                result += [s[:i] + "--" + s[i+2:]]
        return result

Log in to reply
 

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