int main() { std::vector<std::vector<int>> m {{9, 9, 4}, {6, 6, 8}, {2, 1, 1}}; assert(longestIncreasingPath(m) == 4); // 1 -> 2 -> 6 -> 9 m = {{3, 4, 5}, {3, 2, 6}, {2, 2, 1}}; assert(longestIncreasingPath(m) == 4); // 3 -> 4 -> 5 -> 6 return 0; }
int main(int argc, char *argv[]) { int n, m, i, j; n = m = 3; int **mat = malloc(n*sizeof(int*)); for (i=0; i<n; i++) mat[i] = malloc(m*sizeof(int)); mat[0][0] = 3; mat[0][1] = 4; mat[0][2] = 5; mat[1][0] = 3; mat[1][1] = 2; mat[1][2] = 6; mat[2][0] = 2; mat[2][1] = 2; mat[2][2] = 1; printf("ans = %d\n", longestIncreasingPath(mat, n, m)); return 0; }