Skip to content

Commit 14aacf5

Browse files
authored
Create Solution.java
1 parent 016f66f commit 14aacf5

File tree

1 file changed

+16
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)