leetcode498】的更多相关文章

Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Output: [1,2,4,7,5,3,6,8,9] Explanation: Note: The total…
public class Solution { public int[] FindDiagonalOrder(int[,] matrix) { ); ); + col - ; var ary = new int[row * col]; ; ; ; ) { ; m < col; m++) { ary[index++] = matrix[, m]; } return ary; } ) { ; m < row; m++) { ary[index++] = matrix[m, ]; } return…
给定一个含有 M x N 个元素的矩阵(M 行,N 列),请以对角线遍历的顺序返回这个矩阵中的所有元素,对角线遍历如下图所示. 示例: 输入: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] 输出: [1,2,4,7,5,3,6,8,9] 解释: 说明: 给定矩阵中的元素总数不会超过 100000 . //章节 - 数组和字符串 //二.二维数组简介 //1.对角线遍历 /* 算法思想: 有类题属于直观上很好理解,但是写起来却不知如何下手.这题就属于此类. 这…