Find Elements Largest in Row Smallest in Column

Problem Overview

  • Find a matrix element that is largest in its row and smallest in its column; if none exists, print -1.
  • Input: rows and columns, then matrix values (non-negative). Constraints: 1 ≤ N, M ≤ 1000. Output: the qualifying number or -1.
  • Context: matrix/data table analysis in grid-based datasets.
  • From Cisco interviews; a classic coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: