✨ 문제 ✨

✨ 정답 ✨
function solution(begin, target, words){
let count=0;
let visited=[];
if (words.includes(target)){
let queue=[[begin, count]];
while(queue.length){
let [currentWord, count]=queue.shift();
if (currentWord===target){
return count;
}
for (let i=0;i<words.length;i++){
if (visited.includes(words[i])){
continue;
}
let different=0;
for (let j=0;j<currentWord.length;j++){
if (currentWord[j]!==words[i][j]){
different+=1;
}
}
if (different===1){
count+=1;
queue.push([words[i], count]);
visited.push(words[i]);
}
}
}
}else{
return count;
}
}
🧵 참고한 정답지 🧵
💡💡 기억해야 할 점 💡💡