Search a 2D Matrix

You are given an m x n integer matrix matrix and an integer target. Return true if target exists in matrix, or false otherwise.

The matrix has the following properties:

  • Integers in each row are sorted in non-decreasing order from left to right.
  • The first integer of each row is strictly greater than the last integer of the previous row.

Equivalently, concatenating the rows in order (row-major order) produces a single sorted array of m * n integers, so an efficient solution can treat the matrix as one virtual sorted 1D array.

Examples
Input: [[[1,3,5,7],[10,11,16,20],[23,30,34,60]],3]
Output: true
Hints

Search a 2D Matrix

You are given an `m x n` integer matrix `matrix` and an integer `target`. Return `true` if `target` exists in `matrix`, or `false` otherwise.