public static boolean isNonZeroRow(int[][] array2D, int r) {
boolean hasZero = false;
for (int i = 0; i < array2D[r].length(); i++) {
if (array2D[r][i] == 0) {
hasZero = true;
}
}
return hasZero;
}
b)
public static int[][] resize(int[][] array2D) {
int[][] toReturn = new int[numNonZeroRows(array2D)][array2D[0].length];
int k = 0;
for (int i = 0; i < array2D.length; i++) {
if (isNonZeroRow(array2D, r)) {
k++;
for (int j = 0; j < array2D[0].length; j++) {
toReturn[k - 1][j] = array2D[i][j]
}
}
}
return toReturn;
}
Comments
You are seeing this because your Disqus shortname is not properly set. To configure Disqus, you should edit your
_config.yml
to include either adisqus.shortname
variable.If you do not wish to use Disqus, override the
comments.html
partial for this theme.