A saddle point in an \(n \times m\) matrix is an element that is the biggest value on its corresponding row and the smallest value on its corresponding column.
Design and implement an algorithm that returns the saddle point in a given matrix, if it exists. You may assume that all numbers in the matrix are unique.
Write a Python function detectSaddlePoint(matrix: list)
, with a 2-dimensional list (matrix) containing only natural numbers as the argument. The function must return the saddle point of the matrix
.
When the given matrix does not contain a saddle point, it should return None
.
>>> detectSaddlePoint([[7,6], [5,3]])
5
>>> detectSaddlePoint([[8,9,10],[5,2,7],[4,3,11]])
7
>>> detectSaddlePoint([[7,5,3],[1,4,2]])
4
>>> detectSaddlePoint([[8,9,6],[5,2,7],[4,3,11]])