python写算法题:leetcode: 79. Word Search



class Solution(object):
    def checkDirection(self, w, h, board, ch, directions, direction, searchpath, pathmark):
        i,j,_=searchpath[-1]
        pathmark.add((i,j))
        for ind,dd in enumerate(directions[direction:], direction+1):
            di,dj=dd
            if i+di>=0 and i+di=0 and j+dj0 and (i-1,j) not in searchpath and board[j][i-1]==word[ind]:
            #         newpath=searchpath[:]
            #         newpath.append((i-1,j))
            #         nextwmap.append(newpath)
            #     if j>0 and (i,j-1) not in searchpath and board[j-1][i]==word[ind]:
            #         newpath=searchpath[:]
            #         newpath.append((i,j-1))
            #         nextwmap.append(newpath)
            #     if i0

 

你可能感兴趣的:(算法,python)