Challenge: Search in Sorted Matrix

Given a target, tell whether it is present in the matrix or not.

Problem statement

Implement a function that tells whether a given target is present in the sorted matrix or not.

Input

The inputs are a sorted matrix and the target that needs to be checked if it is present or not.

Output

The output should return a boolean variable set to true if the target is found, or false if the target is not found.

Sample input

matrix  = {{10, 11, 12, 13},
          {14, 15, 16, 17},
          {27, 29, 30, 31},
          {32, 33, 39, 80}};

target = 30

Sample output

true

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.