https://school.programmers.co.kr/learn/courses/30/lessons/120869
bool 변수를 하나 추가한뒤 spell의 글자 하나하나 dic의 원소에서 find해서 결과를 bool변수에 &연산 해줌
#include <string>
#include <vector>
using namespace std;
int solution(vector<string> spell, vector<string> dic) {
bool b;
for(const auto& d : dic)
{
b = true;
for(const auto& s : spell)
{
b &= d.find(s) != string::npos;
}
if(b)
return 1;
}
return 2;
}
#include <string>
#include <vector>
using namespace std;
int solution(vector<string> spell, vector<string> dic) {
int answer = 2;
for(const auto& v : dic)
{
bool test = true;
for(const auto& t : spell)
{
if(v.find(t) == string::npos)
{
test= false;
break;
}
}
if(test)
{
answer = 1;
break;
}
}
return answer;
}
find해서 없으면 바로 break해서 멈춤. 탐색 횟수가 훨신 더 적을듯