题解 | #棋子翻转# 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

全部评论

相关推荐

07-07 12:25
门头沟学院 Java
程序员牛肉:你这个智邮公司做的就是那个乐山市税务系统的服务吗?
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务