문제 풀이 : 2021.05.28
뽑은 숫자와 정답 숫자를 비교하여 같은 숫자의 수를 세고, 0의 개수를 계산
최고순위 : 7-(same + zero)
최저순위 : 7-same
same이 0일때는 7등인데 7등이 존재하지 않으므로 예외처리 해야함
class Solution {
public int[] solution(int[] lottos, int[] win_nums) {
int same = 0;
int zero = 0;
for(int lotto : lottos){
if(lotto == 0){
zero ++;
}
else{
for(int num : win_nums){
if(lotto == num){
same++;
break;
}
}
}
}
int high = 7-(same+zero);
int low = 7-same;
if(low==7) low = 6;
if(high==7) high = 6;
int[] answer = {high, low};
return answer;
}
}