class Solution { class Node{ int val; int row; int col; public Node(int row,int col,int val){ this.val = val; this.row = row; this.col = col; } } public int[][] matrixRankTransform(int[][] matrix) { int m = matrix.length;//矩阵的行 int n = matrix[0].length;//矩阵的列 int[] rowRank = new int[m];//行的当前的秩 int[] colRank = new int[n];//列的当前秩 Node[] nodes = new Node[m*n]; int[][] ans = new int[m][n]; int index = 0; for(int i = 0;i < m;i++){//根据matrix创建node for(int j = 0;j < n;j++){ nodes[index++] = new Node(i,j,matrix[i][j]); } } Arrays.sort(nodes, new Comparator
Java对数组进行排序
时间:2023-06-10
上一篇:自定义拦截器和注解
下一篇:File,Lambda
相关推荐