function printPermutationRows(matrix, givenrow) {
const rows = matrix.length;
const cols = matrix[0].length;
let st = new Set();
for (let j = 0; j < cols; j++) {
st.add(matrix[givenrow][j]);
}
for (let i = 0; i < rows; i++) {
if (i == givenrow) {
continue;
}
let j = 0;
for (; j < cols; j++) {
if (!st.has(matrix[i][j])) {
break;
}
}
if (j != cols) {
continue;
}
console.log(i);
}
}
const givenrow = 1;
const matrix = [[7, 9, 4, 3, 1],
[4, 7, 9, 1, 3],
[4, 7, 8, 1, 2],
[1, 6, 9, 2, 4],
[9, 1, 3, 7, 4]];
printPermutationRows(matrix, givenrow);
/*
run:
0
4
*/