class Solution {
public int[][] diagonalSort(int[][] mat) {
int m = mat.length, n = mat[0].length;
for(int k = 0; k < Math.min(m, n); k++) {
for(int i = 0; i< m - 1; i++) {
for(int j = 0; j < n - 1; j++) {
if(mat[i][j] > mat[i + 1][j + 1]) {
int temp = mat[i][j];
mat[i][j] = mat[i +1][j + 1];
mat[i + 1][j +1] = temp;
}
}
}
}
return mat;
}
}
LeetCode 1329按矩阵对角线排序(java)
最新推荐文章于 2024-07-18 09:43:25 发布