# 240909

문제 : [카드 뭉치](https://school.programmers.co.kr/learn/courses/30/lessons/159994)\
난이도 : Lv.1

## 풀이

```javascript
function solution(cards1, cards2, goal) {
    let index1 = 0;  // cards1의 현재 인덱스
    let index2 = 0;  // cards2의 현재 인덱스
    
    // goal의 단어를 순서대로 확인
    for (let word of goal) {
        // cards1에서 단어를 사용해야 할 경우
        if (index1 < cards1.length && cards1[index1] === word) {
            index1++;  // cards1의 다음 단어로 이동
        }
        // cards2에서 단어를 사용해야 할 경우
        else if (index2 < cards2.length && cards2[index2] === word) {
            index2++;  // cards2의 다음 단어로 이동
        }
        // 둘 다 아닐 경우 목표 단어 배열을 만들 수 없음
        else {
            return "No";
        }
    }
    
    // 모든 단어가 성공적으로 사용되었을 경우
    return "Yes";
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jiwons-organization.gitbook.io/jiwon0995/dev-note/index-8/240909.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
