로또의 최고 순위와 최저 순위

suhan cho·2022년 6월 27일
0

처음풀이

class Solution3 {
    public int[] solution(int[] lottos, int[] win_nums) {
        int[] answer = new int[2];

        int best=0;
        int worst=0;

        for(int i=0; i<lottos.length; i++){
            for(int j =0; j<win_nums.length; j++){
                if(lottos[i] == win_nums[j]) worst++;
            }
            if(lottos[i]==0) best++;
        }

       answer[0] = Math.min(7-(best+worst),6);
       answer[1] = Math.min(7-(worst),6);

        return answer;
    }
}
profile
안녕하세요

0개의 댓글