forked from damaohongtu/JavaInterview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearchA2DMatrixII_240.java
More file actions
46 lines (39 loc) · 883 Bytes
/
SearchA2DMatrixII_240.java
File metadata and controls
46 lines (39 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package LeetCode;/**
* @Classname SearchA2DMatrixII_240
* @Description TODO
* @Date 19-5-21 下午4:48
* [
* [1, 4, 7, 11, 15],
* [2, 5, 8, 12, 19],
* [3, 6, 9, 16, 22],
* [10, 13, 14, 17, 24],
* [18, 21, 23, 26, 30]
* ]
*
* Given target = 5, return true.
*
* Given target = 20, return false.
* @Created by mao<[email protected]>
*
*/
public class SearchA2DMatrixII_240 {
//暴力求解
public boolean searchMatrix(int[][] matrix, int target) {
int m=matrix.length;
if(m==0){
return false;
}
int n = matrix[0].length;
for (int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(matrix[i][j]==target){
return true;
}
if(true){
}
}
}
return false;
}
// 优化
}