Notice
Recent Posts
Recent Comments
Link
- Today
- Total
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 인공지능
- jlpt
- 진짜학습지후기
- 진짜학습지
- webflux
- errorhandling
- Android
- n3문법
- Kotlin
- 일본어기초
- 책리뷰
- CustomTab
- androidstudio
- 학습지
- PR
- suspend
- posting
- GIT
- blog
- 일본어문법
- ai
- KotlinInAction
- github
- coroutine
- 안드로이드
- 진짜일본어
- rxjava
- 책추천
- pullrequest
- 코틀린
Archives
코딩하는 개굴이
BaekJoon/BOJ [JAVA] 숫자카드_10815 본문
반응형
BaekJoon/BOJ [JAVA] 숫자카드_10815
단계: Hashmap을 써서 있는지 없는지 체크하자
import java.util.*;
public class baekjoon_10815 {
public static void main(String [] argc){
Scanner scanner = new Scanner(System.in);
int n = Integer.parseInt(scanner.next());
HashMap<Integer, Integer> hashMap = new HashMap<>();
ArrayList<Integer> arrayList = new ArrayList<>();
for(int i=0;i<n;i++){
int tmp = Integer.parseInt(scanner.next());
if(!hashMap.containsKey(tmp)) hashMap.put(tmp, 1);
}
int m = Integer.parseInt(scanner.next());
for(int j=0;j<m;j++){
int check = Integer.parseInt(scanner.next());
if(hashMap.containsKey(check)) arrayList.add(hashMap.get(check));
else arrayList.add(0);
}
for(int z=0;z<m;z++) System.out.print(arrayList.get(z)+" ");
System.out.println();
}
}
반응형
'알고리즘 > Baekjoon' 카테고리의 다른 글
BaekJoon/BOJ [JAVA] 세 수_10817 (0) | 2018.11.25 |
---|---|
BaekJoon/BOJ [JAVA] 시험 성적_9498 (0) | 2018.11.25 |
BaekJoon/BOJ [JAVA] 숫자카드2_10816 (0) | 2018.11.16 |
BaekJoon/BOJ [JAVA] 빠른 A+B_15552 (0) | 2018.11.16 |
BaekJoon/BOJ [JAVA] 열 개씩 끊어 출력하기_11721 (0) | 2018.11.16 |
Comments