관리 메뉴

Jerry

[#85][프로그래머스][입문] 외계어 사전 본문

Problem Solving/Algorithm 문제 풀기

[#85][프로그래머스][입문] 외계어 사전

juicyjerry 2023. 1. 26. 00:56
반응형
function solution(spell, dic) {
  const isExist = [];

  dic.forEach((e) => {
    let cnt = 0;
    spell.forEach((i) => {
      if (e.includes(i)) cnt++;
    });

    if (cnt === spell.length) isExist.push(e);
  });
  return isExist.length === 0 ? 2 : 1;
}
반응형