프로그래머스 120869 외계어 사전

1 개요[ | ]

프로그래머스 120869 외계어 사전

2 C++[ | ]

#include <string>
#include <vector>
#include <algorithm>
using namespace std;

bool isOK(vector<string> spell, string word) {
    if(spell.size() != word.length()) {
        return false;
    }
    for(auto& s: spell) {
        if(word.find(s) == string::npos) {
            return false;
        }
    }
    return true;
}

int solution(vector<string> spell, vector<string> dic) {
    for(string& word: dic) {
        if(isOK(spell, word)) {
            return 1;
        }
    }
    return 2;
}