Description
Solutions
Submission
Find Number in Matrix 🌺
🤘 INTERN

Input

The first line of input consists of two space-separated integers- matrix_row and matrix_col, representing the number of rows in the matrix (N) and the number of columns in the matrix (M), respectively. The next M lines consist of N space-separated integers representing the elements of the matrix.

Output

Print a number which is largest in a row and smallest in a column in the given matrix. If no element is found print "-1".

Example 1:

Input:  matrix = [[1, 2], [3, 4]]
Output: 2
Explanation:
The number 2 at index (0,1) is the largest in its row and smallest in its column. So, the output is 2.
Constraints:
    1 ≤ N, M ≤ 1000
    Note: Each number in the matrix is a non-negative integer.
Thumbnail 0
Testcase

Result
Case 1

input:

output: