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 60bb25e commit 14e242cCopy full SHA for 14e242c
java/0074-search-a-2d-matrix.java
@@ -4,9 +4,13 @@ class Solution {
4
public boolean searchMatrix(int[][] matrix, int target) {
5
int i = 0, j = matrix[0].length - 1;
6
while (i < matrix.length && j >= 0) {
7
- if (matrix[i][j] == target) return true; else if (
8
- matrix[i][j] > target
9
- ) j--; else i++;
+ if (matrix[i][j] == target) {
+ return true;
+ } else if (matrix[i][j] > target) {
10
+ j--;
11
+ } else {
12
+ i++;
13
+ }
14
}
15
return false;
16
0 commit comments