Skip to content

[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

Merged
merged 9 commits into from
Sep 22, 2024
Merged

[2주차] 백제완 #16

merged 9 commits into from
Sep 22, 2024

Conversation

Jewan1120
Copy link
Contributor

No description provided.

// Rank를 이용한 Union
// Rank: 트리의 대략적인 높이
// 높이가 작은 트리를 높이가 큰 트리 아래에 붙여 트리의 높이가 불필요하게 커지지 않도록 함
// Rank가 작은 트리를 큰 트리에 붙임으로써, 트리의 깊이가 크게 증가하지 않으므로, Find 연산 최적화
Copy link
Contributor

Choose a reason for hiding this comment

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

Rank를 사용하면 find연산을 최적화할 수 있군요,,,

배워갑니당,,!!

Copy link
Contributor Author

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];
// 현재 좌표의 그룹과 다음 좌표의 그룹이 다를 경우
Copy link
Contributor

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); // 이분탐색으로 적절한 위치 반환
Copy link
Contributor

Choose a reason for hiding this comment

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

오 Arrays.binarySearch()함수와 보수연산으로 깔끔하게 구현을 할 수 있군요!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

중복없는 배열에서 이분탐색할 때 사용하면 좋은 메서드 같아요~!

@Jewan1120 Jewan1120 merged commit bc23554 into GreatAlgorithm-Study:main Sep 22, 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.

4 participants