DIY: Searching a 2D Matrix
Explore how to implement an efficient search algorithm for a target value in a 2D matrix where each row is sorted, and the first element of each row is greater than the last of the previous. Learn to write the search_matrix function in Ruby that returns a Boolean indicating the presence of the target. This lesson helps you break down matrix search problems commonly seen in coding interviews.
We'll cover the following...
We'll cover the following...
Problem statement
Given an m x n integer matrix and a target value, determine if the target exists in the matrix or not.
The matrix has the following properties:
Integers in each row are sorted ...