🚀 **이 문서는 보다 쉽게 이해할 수 있도록 정리되었습니다.**
여러개의 그룹이 있을 때 합쳐서 값을 찾을 때 사용하는 알고리즘이다.
“`
public class Union_Find {
static int[] parent = new int[10];
public static void main(String []args){
for(int j = 0 ; j < parent.length; j++){
parent[j] = j;
}
}
union(1, 9);
union(3, 6);
union(6, 7);
union(9, 5);
union(6, 8);
System.out.println(find(1,8));
}
private static void union(int a, int b){
int x = getParent(a);
int y = getParent(b);
if(x > y){
union[y] = union[x];
} else {
union[x] = union[y];
}
}
private static boolean find(int a, int b){
int x = getParent(a);
int y = getParent(b);
return x == y;
}
private static int getParent(int a){
if(parent[a] == a)
return a;
return parent[a] = getParent(parent[a]);
}
}
“`
개발자, 기술사, 삼성, 외국계 IT기업 20년차 기술노트 알렉이 직접 작성한
IT기업 기술 면접을 위한 CS + 면접 노하우 PDF
[https://kmong.com/self-marketing/539751/LUA54VnQsP](https://kmong.com/self-marketing/539751/LUA54VnQsP)
자주 나오는 CS 질문과 답변 그리고 100번 이상 면접관으로 참여하면서 느꼈던
면접자가 알아야 할 팁 13가지 포함
백엔드 개발자를 위한 클라우드 강의, AWS
[https://inf.run/o1NX](https://inf.run/o1NX)
이제는 비전공자도, 일반이도 개발할 수 있다.
ChatGPT를 이용한 누구나 앱개발 with 알렉
[https://inf.run/rpX4](https://inf.run/rpX4)
백엔드 직접 번역한 도서
[https://www.yes24.com/Product/Goods/122536127](https://www.yes24.com/Product/Goods/122536127)
IT기술의 거의 모든 것을 다루는 기술노트with알렉 유투브
[https://www.youtube.com/c/%EA%B8%B0%EC%88%A0%EB%85%B8%ED%8A%B8with%EC%95%8C%EB%A0%89](https://www.youtube.com/c/%EA%B8%B0%EC%88%A0%EB%85%B8%ED%8A%B8with%EC%95%8C%EB%A0%89)