在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ Given a m * n matrix mat and an integer K, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for i - K <= r <= i + K, j - K <= c <= j + K, and (r, c) is a valid position in the matrix. Example 1: Input: mat = [[1,2,3],[4,5,6],[7,8,9]], K = 1 Input: mat = [[1,2,3],[4,5,6],[7,8,9]], K = 2 Constraints: m == mat.length 给你一个 m * n 的矩阵 mat 和一个整数 K ,请你返回一个矩阵 answer ,其中每个 answer[i][j] 是所有满足下述条件的元素 mat[r][c] 的和: i - K <= r <= i + K, j - K <= c <= j + K 示例 1: 输入:mat = [[1,2,3],[4,5,6],[7,8,9]], K = 1 输入:mat = [[1,2,3],[4,5,6],[7,8,9]], K = 2 提示: m == mat.length |
请发表评论