인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

Som's profile image
Som

asked

Introduction to Javascript Algorithm Problem Solving (Coding Test Preparation)

7. Curriculum Design (Q)

이 코드도 맞을까요?

Written on

·

218

·

Edited

0

이렇게 풀어도 맞을까요?

function solution(necc, course) {
  let answer = "YES";
  let lst = [];

  for (c of course) {
    for (n of necc) {
      if (c === n) {
        lst.push(c);
        break;
      }
    }
  }
  let compare = lst.join("");
  if (necc !== compare) answer = "NO";

  return answer;
}

console.log(solution("ABC", "ACBC"));
javascript코딩-테스트

Answer 1

0

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^

아래와 같은 경우는 "YES"가 나와야 합니다.

console.log(solution("ABC", "ABCC"));
Som's profile image
Som

asked

Ask a question