Python easy backtracking not very efficient


  • 0
    W
    def canWin(self, s):
        if len(s) < 2:
            return False
        for i in range(len(s)-1):
            if s[i] == s[i+1] == '+':
                if not self.canWin(s[:i]+"--"+s[i+2:]):
                    return True
        return False

Log in to reply
 

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