• 카테고리

    질문 & 답변
  • 세부 분야

    알고리즘 · 자료구조

  • 해결 여부

    미해결

코드리뷰 부탁드리겠습니다.

23.01.25 23:56 작성 조회수 177

0

function solution(str, list) {
    let mustWord = str.split(''); // c, b, a
    let fullWord = list.split('');

    while (fullWord.length !== 0) {
        if (mustWord[mustWord.length-1] === fullWord[fullWord.length-1]) {
            mustWord.pop();
            fullWord.pop();
        } else {
            fullWord.pop();
        }
    }

    return mustWord.length !== 0 ? "NO" : "YES";

답변 1

답변을 작성해보세요.

0

안녕하세요^^

아래 입력은 NO가 나와야 합니다.

console.log(solution("abc", "acbc"));