Find the saddle point of a matrix (an element that is strictly minimum in its row and maximum in its column).
Difficulty: Medium
Phase: 6 · Mixed Logical Challenges
XP Reward: 20 XP
Topics: Mixed Logical Challenges, Medium
Supported Languages: Python, JavaScript, C, C++, Java
Problem Description
Given R and C followed by R x C matrix, find saddle point (minimum in its row, maximum in its column). If exists print value, else '-1'. Input Format: Read input from standard input (stdin). Output Format: Print the result to standard output (stdout).
Constraints
- -10^9 <= N <= 10^9
Examples
Example 1
Input: 3 3 1 2 3 4 5 6 7 8 9
Output: 7
Explanation: Sample execution for input 3 3 1 2 3 4 5 6 7 8 9