🕊 Link

Lv1. 크레인 인형뽑기 게임 Javascript
https://programmers.co.kr/learn/courses/30/lessons/64061

🧑🏻‍💻 Code(javascript)

function solution(board, moves) {
  let answer = 0;
  let box = [];
  for (let move of moves) {
    for (const line of board) {
      if (line[move - 1]) {
        const pickedNum = line[move - 1];
        line[move - 1] = 0;
        if (box[box.length - 1] === pickedNum) {
          box.pop();
          answer++;
        } else {
          box.push(pickedNum);
        }
        break;
      }
    }
  }
  return answer * 2;
}

💡 Solution

👨🏻‍💻💭 Self Feedback


  • 2021.04.15 - 최초 작성

댓글 환영 질문 환영
by.protect-me

profile
protect me from what i want

0개의 댓글

관련 채용 정보