알고리즘/해시

[백준] 17219번 비밀번호 찾기 #Java

VIPeveloper 2022. 6. 19. 15:59
728x90
반응형
import java.io.*;
import java.util.*;

public class Main {

    static HashMap<String,String> hashMap;
    static int n,m,h;

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine()," ");
        n = Integer.parseInt(st.nextToken());
        m = Integer.parseInt(st.nextToken());

        hashMap = new HashMap<>();

        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(br.readLine()," ");
            String url = st.nextToken();
            String password = st.nextToken();
            hashMap.put(url,password);
        }
        for (int i = 0; i < m; i++) {
            st = new StringTokenizer(br.readLine());
            System.out.println(hashMap.get(st.nextToken()));
        }
    }
}
728x90
반응형