반응형

stream 연습 또했네~

import java.util.stream.*;
import java.util.*;

class Solution {
    public int solution(int[] nums) {
        int[] newNum = Arrays.stream(nums)
                        .distinct()
                        .toArray();
        int answer = newNum.length > nums.length/2 ? nums.length/2 : newNum.length;
        return answer;
    }
}

 

반응형

+ Recent posts