Challenge: Search in a 2D List

Given a number, tell whether it is present in the 2D list or not.

Problem statement

Implement a function that tells whether a given number is present in a row-wise and column wise sorted 2D list or not.

Input

A sorted 2D list and the number that needs to be checked if it is present or not

Output

Return True if the target number is found and False otherwise

Sample input

2D_list  =[[10, 11, 12, 13],
           [14, 15, 16, 17],
           [27, 29, 30, 31],
           [32, 33, 39, 50]]

number = 30

Sample output

result = True

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