Matrix Saddle Points
Given an N x M matrix (2D grid) of integers, find all saddle points. A saddle point is an element which is the minimum in its row and the maximum in its column. If multiple saddle points exist, output them in any order. If no saddle points exist, output 'No saddle points'.
Input
The first line contains two integers N and M, the dimensions of the matrix. The next N lines each contain M space-separated integers representing the elements of the matrix.
Output
Print the coordinates (row, column) of each saddle point, separated by spaces. Row and column are 0-indexed. If no saddle points exist, print 'No saddle points'.
Constraints
1 <= N, M <= 1000. The values in the matrix are integers between -10^9 and 10^9.
Example 1
3 3 1 2 3 4 5 6 7 8 9
2 0
Element 7 is min in its row (row 2) and max in its column (column 0). Coordinates are (2, 0).
Example 2
2 2 3 3 3 3
0 0 0 1 1 0 1 1
All elements are saddle points as they are minimum in their row and maximum in their column. Coordinates are (0, 0), (0, 1), (1, 0), (1, 1).
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
3 3 1 2 3 4 5 6 7 8 9
2 2 3 3 3 3