[프로그래머스] 카드 뭉치 - c++

삼식이·2025년 5월 23일
0

알고리즘

목록 보기
58/81

카드 뭉치

#include <string>
#include <vector>

using namespace std;

string solution(vector<string> cards1, vector<string> cards2, vector<string> goal) {
    string answer = "No";
    int check = 0;
    int tmp1 = 0;
    int tmp2 = 0;
    for(int i=0; i<goal.size(); i++) {
        string now = goal[i];
        if (cards1[tmp1] == now) {
            tmp1++;
            check++;
        }
        if (cards2[tmp2] == now) {
            tmp2++;
            check++;
        }
    }
    if (check == goal.size()) answer = "Yes";
    return answer;
}

0개의 댓글