🌟 문제
🍀 문제 답안
class Solution {
public int solution(String[] spell, String[] dic) {
int answer = 0;
int count = 0;
for(int i = 0; i < dic.length; i++){
for(int j = 0; j < spell.length; j++){
if(dic[i].contains(spell[j]))
count++;
}
if(count == spell.length){
answer = 1;
break;
}
else
answer = 2;
count = 0;
}
return answer;
}
}
🍡 답안 풀이
string 배열을 사용해서 spell의 문자열이 dic에 포함되어있으면 count를 해서 spell의 length와 같으면 즉, 알파벳이 한단어에 다 있으면 answer = 1로 반환, 아니면 2로 반환.
1분만에 푼 문젠데 전엔 왤케 오래 걸린건지 참...!