Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
24 lines (22 loc) · 733 Bytes

File metadata and controls

24 lines (22 loc) · 733 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package ch18;
public class P74_1 {
public boolean searchMatrix(int[][] matrix, int target) {
int row = 0;
// 첫 행의 맨 뒤로 지정
int col = matrix[0].length - 1;
// 포인터가 행렬내에 있다면 계속 탐색
while (row < matrix.length && col >= 0) {
// 정답을 찾은 경우 true 리턴
if (matrix[row][col] == target) {
return true;
// 타깃보다 크면 왼쪽으로 이동
} else if (matrix[row][col] > target) {
col--;
// 타깃보다 작은 경우이므로 아래로 이동
} else {
row++;
}
}
return false;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.