Skip to content

Commit 1356625

Browse files
Time: 0 ms (100.00%), Space: 41.8 MB (92.76%) - LeetHub
1 parent 041e7e6 commit 1356625

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public boolean searchMatrix(int[][] matrix, int target) {
3+
int x=0;
4+
boolean isFound=false;
5+
if(target>=matrix[matrix.length-1][0]){
6+
x=matrix.length-1;
7+
}
8+
else{
9+
for(int i=0;i<matrix.length-1;i++){
10+
if(target>=matrix[i][0] && target < matrix[i+1][0]){
11+
x=i;
12+
}
13+
}
14+
}
15+
for(int i=0;i<matrix[0].length;i++){
16+
if(matrix[x][i]==target){
17+
isFound=true;
18+
}
19+
}
20+
return isFound;
21+
}
22+
}

0 commit comments

Comments
 (0)