For this Question: Nutan is a college student. Nutan arrived at college and listened to his friends discussing 'loyal' numbers in a matrix. But Nutan had no idea what 'loyal' numbers were, so he asked his friends. A 'loyal' number, according to one of his friends, is a matrix element that is the smallest in its row and the largest in its column.
Now it's time to test Nutan's understanding. He is given a m x n matrix of distinct numbers and is asked to return all ‘loyal’ numbers in any order.
As a friend of Nutan, help him to solve the problem.The first line contains the numbers of rows r and number of columns c as space separated.
For the next r lines, contains the c elements of the matrix each line as a space separated.

<b>Constraints</b>
m == mat. length
n == mat[i]. length
1 <= n, m <= 10
-100 <= matrix[i][j] <= 100.
All elements in the matrix are distinct.Print the elements of the array containing the loyal numbers in a single line space separated, if it's not present then print -1.Sample Input
2 2
7 8
1 2
Sample Output 
7
Explanation
7 is the only loyal number since it is the minimum in its row and the maximum in its column., I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
    public static void main (String[] args) {

     Scanner sc=new Scanner(System.in);
     int m=sc.nextInt();
     int n=sc.nextInt();

     int[][]mat=new int[m][n];
     for(int i=0;i<m;i++){
         for(int j=0;j<n;j++){
             mat[i][j]=sc.nextInt();
         }
     }

     Vector<Integer> ans = new Vector<Integer>();

     ans = minmaxNumbers(mat,ans);

     if(ans.size()==0){
         System.out.println("-1");
     }

     for(int i=0;i<ans.size();i++){
         System.out.println(ans.get(i));
     }
    }

    public static Vector<Integer> minmaxNumbers(int[][] matrix, Vector<Integer> res)
    {
        Set<Integer> set = new HashSet<Integer>();

        for(int i=0;i<matrix.length;i++){
            int minr = Integer.MAX_VALUE;
            for(int j=0;j<matrix[i].length;j++){
                minr = Math.min(minr,matrix[i][j]);
            }
            set.add(minr);
        }

        for(int j=0;j<matrix[0].length;j++){
            int maxc =Integer.MIN_VALUE;
            for(int i=0;i<matrix.length;i++){
                maxc = Math.max(maxc,matrix[i][j]);
            }
           if(set.contains(maxc)){
               res.add(maxc);
           }
        }
        return res;

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