프로그래머스 - 과일 장수

차관호·2023년 8월 20일

문제링크 - 프로그래머스 - 과일 장수

import java.util.*;
class Solution {
    public int solution(int[] nums) {
     int[] answer = Arrays.stream(nums).distinct().toArray();
         int count = nums.length/2;

        if(count >= answer.length) return answer.length;
        else return count;
    }
}
profile
안녕하세요 :-)

0개의 댓글