안녕하세요.
11월 목표였던 0단계를 끝마치지는 못했네요..
그래도 힘내서 문제를 풀어봅시다.
정답률 71% 외계어 사전 문제입니다.
function solution(spell, dic) {
dic=dic.map(x => [...x]);
spell.forEach(e => {
dic.map(x => x.indexOf(e) > -1?x[x.indexOf(e)] = '':x.push('?'))
})
return dic.map(x => x.join('')).filter(el => el === "").length > 0?1:2;
}
(추가!!)
function solution(spell, dic) {
return dic.map(x=>[...x].sort().join('')).includes(spell.sort().join(''))?1:2;
}