For this Question: Given an integer N and a matrix of size (N x N). Check whether given matrix is identity or not.

<b> Note </b>
An identity matrix is a square matrix in which all the elements of principal diagonal are one, and all other elements are zeros.First line contain a single integer N
Next N line contain N space- separated integer i. e. elements of matrix.If the given matrix is the identity matrix. print "Yes" otherwise print "NO"

Constraints:
1<=N<=100Sample Input 1:
3
1 0 0
0 1 0
0 0 1

Sample Output 1:
Yes

Explanation:
Given matrix is an identity matrix because all main diagonal elements are 1 and rest of elements are 0., I have written this Solution Code: import java.util.*;

import java.io.*;

 

public class Main {

   public static void main(String args[] ) throws Exception {

       

       Scanner s = new Scanner(System.in);

       int N = s.nextInt();
       int [][]arr=new int[N][N];
       for(int i=0;i<N;i++){
           for(int j=0;j<N;j++)
           arr[i][j] = s.nextInt();
       }
       boolean flag=false;
        for(int i=0;i<N;i++){
           for(int j=0;j<N;j++)
           {
               if(i==j && arr[i][j]!=1)flag=true;
               else if(i!=j && arr[i][j]!=0)flag=true;
           }
       }
       if(flag==true){
           System.out.println("No");
       }
       else {
           System.out.println("Yes");
       }
   }

}, In this Programming Language: Java, Now tell me if this Code is compilable or not?