[백준/Java] 10807 : 개수 세기

SEOP·2024년 6월 27일
0

import java.io.*;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int firstInput =  Integer.parseInt( br.readLine());
        List<Integer> list = Arrays.stream(br.readLine().split(" ")).map(it -> Integer.parseInt(it)).collect(Collectors.toList());
        int needToFind = Integer.parseInt( br.readLine());
        int result = 0;

        for (Integer integer : list) {
            if(integer == needToFind){
                result++;
            }
        }
        
        bw.write(String.valueOf(result));

        bw.flush();
        bw.close();
    }
}
profile
응애 나 애기 개발자

0개의 댓글