[21720]楽透の最高順位



質問:https://programmers.co.kr/learn/courses/30/lessons/77484
class Solution {
    public int[] solution(int[] lottos, int[] win_nums) {
        int[] answer = {0,0};
        int matched = 0;
        int zeroCnt = 0;

       for(int i : lottos) {
           if(i == 0) zeroCnt++;
           else {
               for(int l : win_nums){
                   if( i == l ) {
                       matched++;
                       break;
                   }
               }
           }
       }
        int min = matched;
        int max = matched + zeroCnt;
        
        answer[0] = Math.min(7 - max, 6);
        answer[1] = Math.min(7 - min, 6);
        return answer;
    }
}
答え[0]は最高順位なので7-maxです
答え[1]は最低、7-min
🕺拡張for文、配列値を直接比較できます