2023. 10. 17. 00:42ㆍAlgorithm/JAVA
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int n = in.nextInt();
Main t = new Main();
int[][] arr = new int[n+1][6];
for(int i = 1; i<= n;i++) {
for(int j = 1; j<=5 ;j++) {
arr[i][j] = in.nextInt();
}
}
System.out.print(t.solution(n, arr));
}
private static int solution(int n, int[][] arr) {
int answer=0;
int max = -1;
for(int i = 1; i <=n ; i++) {
int cnt=0;
for(int j = 1; j<= n; j++) {
for(int k=1; k<=5; k++) {
if(arr[i][k] == arr[j][k]) {
cnt++;
break;
}
}
}
if(cnt > max) {
max= cnt;
answer = i;
}
}
return answer;
}
}
'Algorithm > JAVA' 카테고리의 다른 글
[Algorithm /프로그래머스] 올바른 괄호 (1) | 2023.10.21 |
---|---|
[Algorithm/인프런] 1. 선택 정렬 (1) | 2023.10.18 |
[Algorithm /프로그래머스] 기사단원의 무기 (0) | 2023.08.30 |
[Algorithm /프로그래머스] 과일 장수 (0) | 2023.08.21 |
[Algorithm /프로그래머스] 소수 찾기 (0) | 2023.08.16 |