Skip to content

Conversation

@jewan100
Copy link
Contributor

No description provided.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

마지막에 절대값으로 반환한 이유가 있을까요?

Copy link
Contributor Author

@jewan100 jewan100 Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그러게여..🐹 필요없는 연산입니다!
수정했습니다 ㅎ 감사합니다

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호.. 다들 휴게소 개수 짱 깔끔하게 구하셨군요..!!👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 왜 빠른 입력 함수만 쓰면 에러가 날까요?,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 요상합니다,,,,,,,,,,,,,,,,,,,,,,,,,ㅋㅎㅋㅎ,, ㅠㅠ !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나중에 같이 입력함수 이야기해봐요!

int[][] board = new int[n + 1][m + 1];
// 웅덩이가 있는 위치 표시
for (int[] puddle : puddles)
board[puddle[1]][puddle[0]] = -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 웅덩이가 있는 곳을 2차원 boolean 배열을 만들어서 저장해줬는데, 그냥 int형 배열에 모두 다 저장해줘도 됐군요,,,,👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

최대한 하나의 배열에서 끝내려고 -1로 표기했더니 계산도 간단해지고 괜찮더라구요!

// 현재 위치가 웅덩이가 아니라면
if (board[i][j] != -1) {
int up = Math.max(0, board[i - 1][j]); // 위쪽에서 오는 경우
int lf = Math.max(0, board[i][j - 1]); // 왼쪽에서 오는 경우
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 최댓값으로 바로 받아와도 되는군요..!! 👍 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

최댓값으로 0과 함께 받아오면 체크해둔 -1을 무시할 수 있어요!

l++;
}
r--;
answer++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

따로 else문 필요 없이 한번에 증가도 가능하군요...!!
저는 2명 타는 경우랑 1명 타는 경우 이렇게 나눠서 생각 하다보니 else문으로 나눠줬었는데, 불필요한 구현 없이 깔끔한 코드 배워갑니다!👍

@baexxbin baexxbin merged commit aea2f2c into GreatAlgorithm-Study:main Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants