Tap here to switch tabs
Problem
Submissions

Problem: Find Smallest Common Element in All Rows

med
30 min
Try to solve the Find Smallest Common Element in All Rows problem.

Statement

Given an m by n matrix mat where each row is sorted in strictly increasing order, return the smallest element that appears in every row of mat. If no such common element exists, return −1-1.

Constraints:

  • m == mat.length

  • n == mat[i].length

  • 1≤1 \leq m, n ≤500\leq 500

  • 1≤1 \leq mat[i][j] ≤104\leq 10^4

  • mat[i] is sorted in strictly increasing order.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Smallest Common Element in All Rows

med
30 min
Try to solve the Find Smallest Common Element in All Rows problem.

Statement

Given an m by n matrix mat where each row is sorted in strictly increasing order, return the smallest element that appears in every row of mat. If no such common element exists, return −1-1.

Constraints:

  • m == mat.length

  • n == mat[i].length

  • 1≤1 \leq m, n ≤500\leq 500

  • 1≤1 \leq mat[i][j] ≤104\leq 10^4

  • mat[i] is sorted in strictly increasing order.