Skip to content

Commit 14e242c

Browse files
committed
format if-else statement to readable code
1 parent 60bb25e commit 14e242c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

java/0074-search-a-2d-matrix.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ class Solution {
44
public boolean searchMatrix(int[][] matrix, int target) {
55
int i = 0, j = matrix[0].length - 1;
66
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++;
7+
if (matrix[i][j] == target) {
8+
return true;
9+
} else if (matrix[i][j] > target) {
10+
j--;
11+
} else {
12+
i++;
13+
}
1014
}
1115
return false;
1216
}

0 commit comments

Comments
 (0)