반응형
https://programmers.co.kr/learn/courses/30/lessons/77484
문제 설명이 길어서 어려운 문제인줄 알고 긴장했다가 긴장 확 풀렸음..
class Solution {
static int one = 6;
static int two = 5;
static int three = 4;
static int four = 3;
static int five = 2;
public int[] solution(int[] lottos, int[] win_nums)
{
int[] answer = new int[2];
int count = 0;
int zero = 0;
for(int i = 0; i < lottos.length; i++)
{
if(lottos[i] == 0)
{
zero++;
continue;
}
for(int j = 0; j < win_nums.length; j++)
{
if(lottos[i] == win_nums[j])
{
count++;
}
}
}
int high = zero+count;
int low = count;
answer[0] = getNumber(high);
answer[1] = getNumber(low);
return answer;
}
public static int getNumber(int count)
{
if(count == one)
{
return 1;
}
else if(count == two)
{
return 2;
}
else if(count == three)
{
return 3;
}
else if(count == four)
{
return 4;
}
else if(count == five)
{
return 5;
}
else {
return 6;
}
}
}
반응형