Algorithm/프로그래머스

[알고리즘] 정수 찾기 Java

rw- 2023. 6. 15. 20:30
728x90

 

import java.util.Arrays;

class Solution {
    public int solution(int[] num_list, int n) {
        return Arrays.stream(num_list).anyMatch(s -> s == n) ? 1 : 0;
    }
}

 

다른 사람의 풀이

import java.util.stream.IntStream;

class Solution {
    public int solution(int[] numList, int n) {
        return IntStream.of(numList).anyMatch(num -> num == n) ? 1 : 0;
    }
}
728x90
반응형