Hello, I am comparing a vector with each one of the rows of a matrix. I have created a variable so that it indicates when it has reached the end of the vector so that it does not continue comparing. Said variable (called coincidence) I increase it every time I find a match but its value does not increase and I do not understand why. By not increasing, I don't get into the if that compares it with the length of the vector and keeps comparing me. Could someone point me to my mistake or give me a clue about the solution? Thanks in advance.
int[][] matriz = {{2, 4, 6}, {1, 2, 4, 5, 5}, {1, 8, 9}};
int[] vector = {2, 4, 5};
int coincidencia = 0;
for (int i = 0; i < matriz.length; i++) {
for (int j = 0; j < matriz[i].length; j++) {
if (vector.length <= matriz[i].length ) {
for (int k = 0; k < vector.length; k++) {
if (vector[k] == matriz[i][j]) {
System.out.println("Coincidencia en " + "[" + i + "]" + "[" + j + "]");
coincidencia++;
System.out.println(coincidencia);
} else {
coincidencia = 0;
}
}
if(coincidencia == vector.length) {
break;
}
} else{
break;
}
}
}