We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8e545d2 commit 419bb0fCopy full SHA for 419bb0f
bona1122/[week3]Queue/Card_bundle.js
@@ -0,0 +1,28 @@
1
+// https://school.programmers.co.kr/learn/courses/30/lessons/159994
2
+
3
+// 1. 큐를 활용한 방법
4
+const solution1 = (cards1, cards2, goal) => {
5
+ for (let i = 0; i < goal.length; i++) {
6
+ if (goal[i] === cards1[0]) {
7
+ cards1.shift();
8
+ } else if (goal[i] === cards2[0]) {
9
+ cards2.shift();
10
+ } else return "No";
11
+ }
12
+ return "Yes";
13
+};
14
15
+// 2. 포인터를 활용한 방법
16
+const solution2 = (cards1, cards2, goal) => {
17
+ let p1 = 0,
18
+ p2 = 0;
19
20
+ for (const word of goal) {
21
+ if (word === cards1[p1]) {
22
+ p1++;
23
+ } else if (word === cards2[p2]) {
24
+ p2++;
25
26
27
28
0 commit comments