Hello, I have the following question/doubt...
what this code does is given an array multiply its elements by an integer and return it
static int[] multiplicarArray(int[] arr, int k) {
int[] nuevo = new int[arr.length];
for(int i = 0;i < arr.length; i++) {
nuevo[i] = arr[i] * k;
}
return nuevo;
}
what I would like is that, given a matrix, check if one of its columns is the multiplied array, but it would not be working for me (I know that the code below is wrong but it would not be finding the solution)
static boolean existeColumnaMultiplol(int[][] mat, int[] vec, int k) {
boolean res = false;
int[] nuevo = multiplicarArray(vec, k);
for (int i = 0; i < vec.length; i++) {
for (int c = 0; c < mat[0].length; c++) {
for (int f = 0; f < mat.length; f++)
res = res || (mat[f][c] == nuevo[i]);
}
}
return res;
}