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: // C++ program for the above approach

#include <bits/stdc++.h>

using namespace std;

// Function to find all the matrix elements
// which are minimum in its row and maximum
// in its column

vector<int> minmaxNumbers(vector<vector<int> >& matrix, vector<int>& res)
{
        // Initialize unordered set
        unordered_set<int> set;

        // Traverse the matrix
        for (int i = 0; i < matrix.size(); i++) {
                int minr = INT_MAX;
                for (int j = 0; j < matrix[i].size(); j++) {
                        // Update the minimum
                        // element of current row
                        minr = min(minr, matrix[i][j]);
                }
                // Insert the minimum
                // element of the row
                set.insert(minr);
        }
        for (int j = 0; j < matrix[0].size(); j++) {
                int maxc = INT_MIN;
                for (int i = 0; i < matrix.size(); i++) {
                        // Update the maximum
                        // element of current column
                        maxc = max(maxc, matrix[i][j]);
                }
                // Checking if it is already present
                // in the unordered_set or not
                if (set.find(maxc) != set.end()) {
                        res.push_back(maxc);
                }
        }
        return res;
}


// Driver Code
int main()
{
    vector<vector<int>> mat;
    int r, c;
    cin >> r >> c;
    for(int i = 0; i < r; i++){
        vector<int> row;
        for(int j = 0; j < c; j++){
            int value;
                        cin >> value;
                        row.push_back(value);
        }
        mat.push_back(row);
    }
 vector<int> ans;
        // Function call
        minmaxNumbers(mat, ans);
        // If no such matrix
        // element is found
        if (ans.size() == 0)
                cout << "-1" << endl;

        for (int i = 0; i < ans.size(); i++)
                cout << ans[i] << endl;
        return 0;
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?