https://programmers.co.kr/learn/courses/30/lessons/77484
import java.util.*;
public class Solution {
public int[] solution(int[] lottos, int[] win_nums) {
int zero_count = 0;
int check = 0;
for (int l : lottos) {
if (l == 0) zero_count++;
else {
for (int w : win_nums) {
if (l == w) {
check++;
break;
}
}
}
}
int min = check;
int max = check + zero_count;
int[] answer = {Math.min(7-max, 6), Math.min(7-min, 6)};
return answer;
}
}
public class Solution {
public int[] solution(int[] lottos, int[] win_nums) {
int zero_count = 0;
int check = 0;
for (int l : lottos) {
if (l == 0) zero_count++;
else {
for (int w : win_nums) {
if (l == w) {
check++;
break;
}
}
}
}
int min = check;
int max = check + zero_count;
int[] answer = {getGrade(max), getGrade(min)};
return answer;
}
public int getGrade(int n) {
switch(n) {
case 6 :
return 1;
case 5 :
return 2;
case 4 :
return 3;
case 3 :
return 4;
case 2 :
return 5;
default :
return 6;
}
}
}