[프로그래머스 C++]/LEVEL 0

[프로그래머스 C++] 외계어 사전

AKI(JUNI) 2024. 3. 4. 23:14

◈ 문제 설명


◈ 문제 설명 링크
코딩테스트 연습 - 외계어 사전 | 프로그래머스 스쿨 (programmers.co.kr)

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr


◈ 작성 코드

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int solution(vector<string> spell, vector<string> dic) 
{
    int answer = 2;
    int t = 0;
    for(int i = 0; i < dic.size(); i++)
    {
        for(int j = 0; j < spell.size(); j++)
        {
            if(dic[i].find(spell[j]) != string::npos)
            {
                t++;
            }
        }
        if(t >= spell.size())
        {
            answer = 1;
            break;
        }
        t = 0;
    }
    return answer;
}