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

全部评论

相关推荐

程序员花海:最好不要在简历写电商 电商覆盖域太多了 订单 购物车 交易 招商 营销 氛围 履约 售后 用户增长 营销等等一系列都是电商,你写一个这么大的项目是让面试官随便挑一个擅长的来问吗?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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