https://school.programmers.co.kr/learn/courses/30/lessons/42840
if(problemOne[i%5] ==(answers[i]))
배열 [1,2,3,4,5] 의 사이즈가5니간 %5로 무한반복
result= Math.max(Math.max(countOne,countTwo),countThree);
Math.max(요소 3개이상)
int[] answer2 = new int[answer.size()];
for(int i=0 ; i<answer2.length; i++){
answer2[i]=answer.get(i);
}
ArrayList -> int[]배열로 변환
import java.util.*;
class Solution {
public int[] solution(int[] answers) {
List<Integer> answer = new ArrayList<>();
int[] problemOne= {1,2,3,4,5};
int[] problemTwo={2,1,2,3,2,4,2,5};
int[] problemThree={3,3,1,1,2,2,4,4,5,5};
int countOne=0;
int countTwo=0;
int countThree=0;
int result=0;
//1번 수포자 정답 갯수
for(int i =0; i<answers.length;i++){
if(problemOne[i%5] ==(answers[i])){
countOne++;
}
if(problemTwo[i%8] ==(answers[i])){
countTwo++;
}
if(problemThree[i%10] == (answers[i])){
countThree++;
}
result= Math.max(Math.max(countOne,countTwo),countThree);
}
if(result==countOne){
answer.add(1);
}
if(result==countTwo){
answer.add(2);
}
if(result==countThree){
answer.add(3);
}
int[] answer2 = new int[answer.size()];
for(int i=0 ; i<answer2.length; i++){
answer2[i]=answer.get(i);
}
return answer2;
}
}