프로그래머스 - 로또의 최고 순위와 최저 순위 (java)

프로그래머스 - 로또의 최고 순위와 최저 순위 (java)

class Solution {

private int right;

public int [] solution( int [] lottos, int [] win_nums) {

int [] answer = new int [ 2 ];

int count = 0 ;

right = 0 ;

int len = lottos. length ;

for ( int i = 0 ; i < len ;i + + ){

int temp = lottos[i];

if (temp = = 0 ){

count + + ;

} else {

checkRight(win_nums, temp);

}

}

answer[ 0 ] = check(count + right);

answer[ 1 ] = check(right);

return answer;

}

private int check( int num){

switch (num){

case 6 : return 1 ;

case 5 : return 2 ;

case 4 : return 3 ;

case 3 : return 4 ;

case 2 : return 5 ;

default : return 6 ;

}

}

private void checkRight( int [] win_nums, int temp){

int len = win_nums. length ;

for ( int j = 0 ; j < len;j + + ){

if (win_nums[j] = = temp){

right + + ;

return ;

}

}

}

}

from http://kkokkoma-dev.tistory.com/140 by ccl(A) rewrite - 2021-10-12 12:27:58