Starting from the grid (0, 0), going right, the traversal keeps moving forward in one direction, until it hits a boundary or a traversed grid. The direction changes in a loop order: right->down->left->up. In this manner, all grids will be visited exactly once. Time complexity is O(...
/***@parammatrix: a matrix of integers *@return: an array of integers*/publicint[] printZMatrix(int[][] matrix) {//write your code hereintx, y, dx, dy, count, m, n; x= y = 0; count= 1; dx= -1; dy = 1; m=matrix.length; n= matrix[0].length;int[] z =newint[m*...