-
Notifications
You must be signed in to change notification settings - Fork 4
[4주차] 백제완 #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[4주차] 백제완 #49
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
33dda88
백제완: [CT] 토스트 계란틀_240930
Jewan1120 7e8fb73
백제완: [CT] 토스트 계란틀(코드리뷰 반영)_240930
Jewan1120 dc2152f
백제완: [BOJ] 4386 별자리 만들기_241001
Jewan1120 0d7b2c4
백제완: [SQL] 부모의 형질을 모두 가지는 대장균 찾기_241001
Jewan1120 8f75148
백제완: [BOJ] 4386 별자리 만들기(코드리뷰 반영)_241001
Jewan1120 8280e62
백제완: [BOJ] 7570 줄 세우기_241002
Jewan1120 e1076b2
백제완: [BOJ] 1477 휴게소 세우기_241002
Jewan1120 e987d06
백제완: [PG] 42898 등굣길_241003
Jewan1120 0da6646
백제완: [PG] 42885 구명보트_241004
Jewan1120 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
백제완: [PG] 42898 등굣길_241003
- Loading branch information
commit e987d06eb0a208e165ea17ce61bafd9c72c9994d
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Solution { | ||
final int MOD = 1_000_000_007; // 나머지 연산 | ||
public int solution(int m, int n, int[][] puddles) { | ||
int[][] board = new int[n + 1][m + 1]; | ||
// 웅덩이가 있는 위치 표시 | ||
for (int[] puddle : puddles) | ||
board[puddle[1]][puddle[0]] = -1; | ||
board[0][1] = 1; // 시작 위치의 위 혹은 왼쪽을 1로 초기화 | ||
for (int i = 1; i < n + 1; i++) | ||
for (int j = 1; j < m + 1; j++) | ||
// 현재 위치가 웅덩이가 아니라면 | ||
if (board[i][j] != -1) { | ||
int up = Math.max(0, board[i - 1][j]); // 위쪽에서 오는 경우 | ||
int lf = Math.max(0, board[i][j - 1]); // 왼쪽에서 오는 경우 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이렇게 최댓값으로 바로 받아와도 되는군요..!! 👍 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 최댓값으로 0과 함께 받아오면 체크해둔 -1을 무시할 수 있어요! |
||
board[i][j] = (up + lf) % MOD; // 가능한 경우의 수 계산 | ||
} | ||
return board[n][m]; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 웅덩이가 있는 곳을 2차원 boolean 배열을 만들어서 저장해줬는데, 그냥 int형 배열에 모두 다 저장해줘도 됐군요,,,,👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
최대한 하나의 배열에서 끝내려고 -1로 표기했더니 계산도 간단해지고 괜찮더라구요!