algos_and_structures/neetcode/arrays/search_2d_matrix
2025-02-22 13:36:53 +03:00
..
README.md Add solution for neetcode: search_2D_matrix 2025-02-22 13:36:53 +03:00
solution.py Add solution for neetcode: search_2D_matrix 2025-02-22 13:36:53 +03:00

Search a 2D Matrix You are given an m x n 2-D integer array matrix and an integer target.

Each row in matrix is sorted in non-decreasing order. The first integer of every row is greater than the last integer of the previous row. Return true if target exists within matrix or false otherwise.

Can you write a solution that runs in O(log(m * n)) time?

Example 1:

Input: matrix = 1,2,4,8],[10,11,12,13],[14,20,30,40, target = 10

Output: true Example 2:

Input: matrix = 1,2,4,8],[10,11,12,13],[14,20,30,40, target = 15

Output: false Constraints:

m == matrix.length n == matrix[i].length 1 <= m, n <= 100 -10000 <= matrix[i][j], target <= 10000