Helper Function to check if queen can be placed
bool canPlace ( int k , int i ) { for ( int j = 1 ; j <= k - 1 ; j ++ ) { if ( arr [ j ] == i || ( abs ( arr [ j ] - i ) == abs ( j - k ) ) ) return false ; } return true ; }