Resolve NQuees code

when i tried to execute my own code it didn’t work but later when i tried to copy the code from video it didn’t work either (it is giving 0 as output)

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
boolean[][] arr1 = new boolean[4][4];

    System.out.println(countNqueens(arr1, 0));
	
}


public static int countNqueens(boolean[][] arr, int row){
    
    if(row == arr.length){
    return 1;
    
}

int count =0;
    
    for(int col=0; col<arr[row].length; col++){
        
        if(isTrue(arr,row,col)){
            
            arr[row][col] = true;
            
            count = count+countNqueens(arr,row++);
            arr[row][col] = false;
        }
    } return count;
    
  
}


public static boolean isTrue(boolean[][] arr, int row, int col){
    
    for(int i=row; i>=0; i--){
        
        if(arr[i][col]){
            
            return false;
        }
    }
        
   for(int i=row, j= col; i>=0&&j>=0; i--,j--){
        
        if(arr[i][j]){
            
            return false;
        }     
        
   }
        
    for(int i=row, j= col; i>=0&&j<=arr.length; i--,j++){
        
        if(arr[i][j]){
            
            return false;
        }      
        
    }
    
    return true;
    
}

    }

@raja_manoj,
https://ide.codingblocks.com/s/256566 corrected code.

Error:

   for(int i=row, j= col; i>=0&&j<=arr.length; i--,j++){

Here it should be:

    for(int i=row, j= col; i>=0&&j< arr.length; i--,j++){

j<arr.length and not j<=arr.length

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.