Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 730 Bytes

Search_In_Sorted_Matrix.md

File metadata and controls

25 lines (16 loc) · 730 Bytes

Search In Sorted Matrix

Problem Statement

You are given a two-dimensional array (matrix) of distinct integers where each row is sorted and each column is also sorted. The matrix does not necessarily have the same height and width. You are also given a target number, and you must write a function that returns an array of the row and column indices of the target number if it is contained in the matrix and [-1, -1] if it is not contained in the matrix.

Sample input: [ [1, 4, 7, 12, 15, 1000], [2, 5, 19, 31, 32, 1001], [3, 8, 24, 33, 35, 1002], [40, 41, 42, 44, 45, 1003], [99, 100, 103, 106, 128, 1004], ], 44

Sample output: [3, 3]

Solution

Check this Python code.