11import java .util .*;
22
33class Solution {
4+
5+ //각 수포자가 기재한 답 배열 선언
46 static int [] first = {1 ,2 ,3 ,4 ,5 };
57 static int [] second = {2 ,1 ,2 ,3 ,2 ,4 ,2 ,5 };
68 static int [] third = {3 ,3 ,1 ,1 ,2 ,2 ,4 ,4 ,5 ,5 };
79
810 static List <Integer > al = new ArrayList <>();
911
10- public Integer [] solution (int [] answers ) {
12+ public List < Integer > solution (int [] answers ) {
1113
1214 int first_cnt = calc (first , answers );
1315 int second_cnt = calc (second , answers );
1416 int third_cnt = calc (third , answers );
15-
16- int max = Math .max (first_cnt ,second_cnt );
17- max = Math .max (max , third_cnt );
1817
18+ // 가장 많이 맞은 갯수 구하기
19+ int max = Math .max (Math .max (first_cnt ,second_cnt ), third_cnt );
20+
21+ // 가장 많은 문제를 맞힌 사람 구하기(동점자 고려)
1922 if (first_cnt == max ){
2023 al .add (1 );
2124 }
@@ -26,17 +29,16 @@ public Integer[] solution(int[] answers) {
2629 al .add (3 );
2730 }
2831
29- Integer [] answer = new Integer [ al . size ()] ;
30-
31- return al .toArray (answer );
32+ return al ;
33+ // Integer[] answer = new Integer[al.size()];
34+ // return al.toArray(answer);
3235 }
3336
3437 int calc (int [] a , int [] b ){
3538 int cnt = 0 ;
3639
40+ //정답과 기재한 답 비교후 맞은 갯수 구하기
3741 for (int i =0 ; i <b .length ; i ++){
38- System .out .println (b [i ] + " " + a [i %a .length ]);
39-
4042 if (b [i ] == a [i %a .length ]){
4143 cnt ++;
4244 }
0 commit comments