? 矩阵上的问题(3题)
Search a 2D Matrix II
public int searchMatrix(int[][] matrix, int target) { // write your code here int n = matrix.length; if (n == 0) { return 0; } int m = matrix[0].length; if (m == 0) { return 0; } int i = n - 1; int j = 0; int res = 0; while (i >= 0 && j < m) { if (matrix[i][j] == target) { res++; i--; j++; } else if (matrix[i][j] > target) { i--; } else { j++; } } return res; }
? 高精度运算(4题)
? 快速幂(1题)
时间: 2024-10-26 13:41:13