We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c5943dc commit 9be5205Copy full SHA for 9be5205
Java/Search-a-2d-matrix.java
@@ -0,0 +1,29 @@
1
+class Solution {
2
+ public boolean searchMatrix(int[][] matrix, int target) {
3
+
4
+ if(matrix.length == 0 || matrix[0].length == 0){
5
+ return false;
6
+ }
7
8
+ if(matrix[matrix.length-1][matrix[0].length-1] < target){
9
10
11
12
+ for(int i=0; i<matrix.length; i++){
13
+ for(int j=0; j<matrix[i].length; j++){
14
15
+ if(matrix[i][j] > target){
16
17
18
+ else if(matrix[i][j] == target){
19
+ return true;
20
21
+ else{
22
+ continue;
23
24
25
26
27
28
29
+}
0 commit comments