Skip to content

Latest commit

 

History

History
29 lines (25 loc) · 779 Bytes

File metadata and controls

29 lines (25 loc) · 779 Bytes

Search In A Sorted 2d Array

Medium


  1. You are given a number n, representing the number of rows and columns of a square matrix.
  2. You are given n * n numbers, representing elements of 2d array a.
  3. Note- Each row and column is sorted in increasing order.
  4. You are given a number x.
  5. You are required to find x in the matrix and print it's location int (row, col) format as discussed in output format below.
  6. In case element is not found, print "Not Found".

Example 1:

Input:  
n=4, 
arr = { 11 12 13 14 
        21 22 23 24 
        31 32 33 34 
        41 42 43 44  }
Output:  3 2

Constraints:

1 <= n <= 10^2
-10^9 <= e11, e12, .. n * m elements <= 10^9
All rows and columns are sorted in increasing order