-
Notifications
You must be signed in to change notification settings - Fork 4
[2주차] 백제완 #16
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
[2주차] 백제완 #16
Conversation
// Rank를 이용한 Union | ||
// Rank: 트리의 대략적인 높이 | ||
// 높이가 작은 트리를 높이가 큰 트리 아래에 붙여 트리의 높이가 불필요하게 커지지 않도록 함 | ||
// Rank가 작은 트리를 큰 트리에 붙임으로써, 트리의 깊이가 크게 증가하지 않으므로, Find 연산 최적화 |
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.
Rank를 사용하면 find연산을 최적화할 수 있군요,,,
배워갑니당,,!!
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.
맞슴다..! 혹시 모르니 항상 최적화된 방식으로 구현하려고 하고 있어여
for (int k = 0; k < 2; k++) { | ||
int y = i + dy[k]; | ||
int x = j + dx[k]; | ||
// 현재 좌표의 그룹과 다음 좌표의 그룹이 다를 경우 |
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.
두 좌표를 비교하는 것이 두 그룹을 비교하는 것과 같은 로직이라는 것이 좋은 아이디어인 것 같습니다! 👍
int len = 0; // LIS의 길이 | ||
for (int i = 0; i < n; i++) { | ||
int value = read(); | ||
int idx = Arrays.binarySearch(arr, 0, len, value); // 이분탐색으로 적절한 위치 반환 |
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.
오 Arrays.binarySearch()함수와 보수연산으로 깔끔하게 구현을 할 수 있군요!!
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.
중복없는 배열에서 이분탐색할 때 사용하면 좋은 메서드 같아요~!
No description provided.