74 Search a 2D Matrix
74. Search a 2D Matrix
題目描述
You are given an m x n
integer matrix matrix
with the following two properties:
- Each row is sorted in non-decreasing order.
- The first integer of each row is greater than the last integer of the previous row.
Given an integer target
, return true
if target
is in matrix
or false
otherwise.
You must write a solution in O(log(m * n))
time complexity.
範例
Example 1:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Example 2:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Constraints:
m
== matrix.length
n
== matrix[i].length
- 1 <=
m
, n
<= 100
- -104 <=
matrix[i][j]
, target
<= 104
解答
C#
JimAug 7, 2023
C++
Jerry Wu7 August, 2023
Javascript
MarsgoatAug 7, 2023
Reference
回到題目列表