DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
Binary Search

Search a 2D Matrix

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Search a 2D Matrix** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Treat matrix as flat sorted array, index mapping **Edge Cases to Consider:** - (1) Target outside range - (2) 1×1 matrix - (3) Target at edges

Examples

Example 1
Input: [[1,3,5,7],[10,11,16,20],[23,30,34,60]], 3
Output: true
Explanation: Found
Example 2
Input: [[1,3,5,7],[10,11,16,20],[23,30,34,60]], 13
Output: false
Explanation: Not found
Example 3
Input: [[1]], 1
Output: true
Explanation: 1×1 found

Constraints

  • ▪Input arguments are within valid ranges
  • ▪Optimize for execution speed
  • ▪Handle null/empty inputs gracefully

Watch Out For Edge Cases

  • ▪Target outside range
  • ▪1×1 matrix
  • ▪Target at edges
Frequently Asked At
AmazonMicrosoftGoogleAdobeTCS