문제 출처: https://programmers.co.kr/learn/courses/30/lessons/77484
import java.util.HashSet;
import java.util.Set;
class Solution {
public int[] solution(int[] lottos, int[] win_nums) {
int[] answer = new int[2];
Set<Integer> set = new HashSet<>();
for (int i = 0; i < 6; i++) {
set.add(win_nums[i]);
}
int zeroCnt = 0;
int winCnt = 0;
for (int i = 0; i < 6; i++) {
if (lottos[i] == 0) zeroCnt++;
else {
if (set.contains(lottos[i])) winCnt++;
}
}
int max = winCnt + zeroCnt;
answer[0] = (7 - max) > 5 ? 6 : (7 - max);
answer[1] = (7 - winCnt) > 5 ? 6 : (7 - winCnt);
return answer;
}
}