Function returns true if the move taken is valid else it will return false .
function isSafe ( row , col , m , n , visited ) { if ( row == - 1 row == n col == - 1 col == n visited [ row ] [ col ] m [ row ] [ col ] == 0 ) return false ; return true ; }