Skip to content

Commit 3242ae9

Browse files
refactor 74
1 parent c2856a8 commit 3242ae9

File tree

1 file changed

+3
-24
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+3
-24
lines changed

src/main/java/com/fishercoder/solutions/_74.java

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,13 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 74. Search a 2D Matrix
5-
*
6-
* Write an efficient algorithm that searches for a value in an m x n matrix.
7-
* This matrix has the following properties:
8-
9-
Integers in each row are sorted from left to right.
10-
The first integer of each row is greater than the last integer of the previous row.
11-
For example,
12-
13-
Consider the following matrix:
14-
15-
[
16-
[1, 3, 5, 7],
17-
[10, 11, 16, 20],
18-
[23, 30, 34, 50]
19-
]
20-
21-
Given target = 3, return true.
22-
23-
*/
243
public class _74 {
254

265
public static class Solution1 {
276
public boolean searchMatrix(int[][] matrix, int target) {
287
if (matrix == null || matrix.length == 0
29-
|| matrix[0].length == 0
30-
|| matrix[0][0] > target
31-
|| matrix[matrix.length - 1][matrix[0].length - 1] < target) {
8+
|| matrix[0].length == 0
9+
|| matrix[0][0] > target
10+
|| matrix[matrix.length - 1][matrix[0].length - 1] < target) {
3211
return false;
3312
}
3413
int m = matrix.length;

0 commit comments

Comments
 (0)