매일코테

백준 12단계 no.1

공주맛밤 2022. 8. 3. 14:26

import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        HashSet<Integer> set1 = new HashSet<>();

        for (int i = 0; i < n; i++) {
            set1.add(sc.nextInt());
        }

        int m = sc.nextInt();
        int[] arr = new int[m];

        for (int i = 0; i < m; i++) {
            arr[i] = sc.nextInt();
        }

        for (int i = 0; i < arr.length; i++) {
            if (set1.contains(arr[i])) {
                arr[i] = 1;
            } else {
                arr[i] = 0;
            }
        }

        for (int i : arr) {
            System.out.print(i + " ");
        }
    }
}

https://github.com/lhj0954/Baekjoon-codingTest.git

 

GitHub - lhj0954/Baekjoon-codingTest: 백준 코딩 테스트

백준 코딩 테스트. Contribute to lhj0954/Baekjoon-codingTest development by creating an account on GitHub.

github.com

 

728x90
반응형

'매일코테' 카테고리의 다른 글

백준 문제 풀이는 깃허브에 올림  (1) 2022.08.03
백준 11단계 no.5  (0) 2022.07.27
백준 11단계 no.4  (0) 2022.07.27
백준 11단계 no.3  (0) 2022.07.27
백준 11단계 no.2  (0) 2022.07.27