Matrix Search Problem
श्रीः

Matrix Search Problem | DSA Problem Solving

Problem Description
  • We are given a matrix (2D array) having m rows and n columns (m ≥ 1, n ≥ 1).
  • Within each row, the elements are sorted in non-descending order.
    [That is, any element is at least as large as the previous element of the same row.]
  • The 1st element of each row is at least as large as the last element of the previous row.
  • We are also given a target value.
  • Need to determine if the value is present in the matrix or not.
Illustrative Examples

Example 1

Matrix
3558
12141515

Target: 14

Answer: target is present

Example 2

Matrix
27
79
1220

Target: 7

Answer: target is present

Example 3

Matrix
257
101212
121520

Target: 8

Answer: target is not present

Here, we introduced the problem of searching for a value in a sorted matrix. In subsequent posts, we can look at different approaches to solving this.

sri ramanuja seva
Posted in

2 responses to “Matrix Search Problem | DSA Problem Solving”

  1. […] Matrix Search Problem | DSA Problem Solving […]

  2. […] Matrix Search Problem | DSA Problem Solving […]

Leave a Reply