题解 | #棋子翻转# Python3

棋子翻转

https://www.nowcoder.com/practice/a8c89dc768c84ec29cbf9ca065e3f6b4

class Solution:
    def flipChess(self , A: List[List[int]], f: List[List[int]]) -> List[List[int]]:
        # write code here
        M=len(A)
        for pos in f:
            px,py=pos[0]-1,pos[1]-1
            for x,y in [(px-1,py),(px+1,py),(px,py-1),(px,py+1)]:
                if 0<=x<M and 0<=y<M:
                    A[x][y]=1-A[x][y]
        return A

全部评论

相关推荐

05-09 12:23
已编辑
华南理工大学 Java
野猪不是猪🐗:给他装的,双九+有实习的能看的上这种厂我直接吃⑨✌们拿它练练面试愣是给他整出幻觉了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务