File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ package Week2 .공통 .카드뭉치 ;
2
+
3
+ import java .util .*;
4
+
5
+ public class jiyoon {
6
+ class Solution {
7
+ public String solution (String [] cards1 , String [] cards2 , String [] goal ) {
8
+ boolean check = true ; // 문자열 완성 확인용
9
+
10
+ Queue <String > q1 = new LinkedList <>(); // card1의 문자열을 담을 배열
11
+ Queue <String > q2 = new LinkedList <>(); // card2의 문자열을 담을 배열
12
+
13
+ // 각각의 Queue에 cards1과 cards2 담기
14
+ for (int i = 0 ; i < cards1 .length ; i ++) q1 .add (cards1 [i ]);
15
+ for (int i = 0 ; i < cards2 .length ; i ++) q2 .add (cards2 [i ]);
16
+
17
+ for (int i = 0 ; i < goal .length ; i ++) {
18
+ String find = goal [i ];
19
+
20
+ // q1에서 goal[i]를 가져올 수 있는지 확인
21
+ if (q1 .peek () != null && q1 .peek ().equals (find )) {
22
+ q1 .remove ();
23
+ continue ;
24
+ }
25
+
26
+ // q2에서 goal[i]를 가져올 수 있는지 확인
27
+ if (q2 .peek () != null && q2 .peek ().equals (find )) {
28
+ q2 .remove ();
29
+ continue ;
30
+ }
31
+
32
+ // goal[i]를 가져올 수 없다면 check = false;
33
+ check = false ;
34
+ }
35
+ return check ? "Yes" : "No" ;
36
+ }
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments