๋ฐ์ํ
๐ ๋ฌธ์ URL ๐
class Solution {
public int[] solution(int[] lottos, int[] win_nums) {
int[] answer = new int[2];
int cnt = 0;
int zeroCnt = 0;
for(int num : lottos){
if(num ==0){
zeroCnt ++;
}
for(int win_num : win_nums){
if(num == win_num){
cnt++;
}
}
}
int minCnt = cnt;
int maxCnt = cnt+zeroCnt;
answer[0] = getGrade(maxCnt);
answer[1] = getGrade(minCnt);
return answer;
}
public int getGrade(int cnt){
if(cnt == 6){
return 1;
}else if(cnt ==5){
return 2;
}else if(cnt ==4){
return 3;
}else if(cnt ==3){
return 4;
}else if(cnt ==2){
return 5;
}else{
return 6;
}
}
}
ํ
์คํธ ํต๊ณผ~!
728x90
๋ฐ์ํ
'๊ฐ๋ฐ > ์๊ณ ๋ฆฌ์ฆ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค/JAVA] ์ซ์ ๋ฌธ์์ด๊ณผ ์๋จ์ด (0) | 2022.07.24 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค/JAVA] ์ ๊ท ์์ด๋ ์ถ์ฒ (0) | 2022.07.24 |
[ํ๋ก๊ทธ๋๋จธ์ค/JAVA] ์ ๊ณ ๊ฒฐ๊ณผ ๋ฐ๊ธฐ (1) | 2022.07.24 |
[ํ๋ก๊ทธ๋๋จธ์ค/JAVA] ๊ฐ์ฅ ํฐ ์ - ์ ๋ ฌ (0) | 2022.02.20 |
[ํ๋ก๊ทธ๋๋จธ์ค/JAVA] K๋ฒ์งธ์ - ์ ๋ ฌ (0) | 2022.02.20 |
๋๊ธ