Find position of non | Function to find the count of placing non - attacking rooks on the N x N chessboard ; Count of the Non - attacking rooks ; Printing lexographically smallest configuration ; Driver Code ; Function call
function findCountRooks ( row , col , n , k ) { let res = n - k ; document . write ( res + " " ) ; let ri = 0 , ci = 0 ; while ( res -- > 0 ) { while ( ri < k && row [ ri ] == 1 ) { ri ++ ; } while ( ci < k && col [ ci ] == 1 ) { ci ++ ; } document . write ( ( ri + 1 ) + " " + ( ci + 1 ) + " " ) ; ri ++ ; ci ++ ; } } let n = 4 ; let k = 2 ; let row = [ 1 , 2 ] ; let col = [ 4 , 2 ] ; findCountRooks ( row , col , n , k ) ;