function solution(msg){
msg=msg.split('');
let messageCopy=msg.slice();
let answer=[];
let alphabets={};
let indexIs=27;
for (let i=1;i<='Z'.charCodeAt()-64;i++){
alphabets[String.fromCharCode(i+64)]=i;
}
while(messageCopy.length){
let w=messageCopy.shift();
let c='';
for (let i=0;i<messageCopy.length;i++){
let newW=w+messageCopy[i];
if (alphabets[newW]!==undefined){
w=newW;
c=messageCopy[i+1];
}else{
c=messageCopy[i];
break;
}
}
if (c!==undefined){
answer.push(alphabets[w])
alphabets[w+c]=indexIs;
indexIs+=1;
messageCopy.splice(0, w.length-1)
}else{
answer.push(alphabets[w])
messageCopy.splice(0, w.length-1)
}
}
return answer;
}
분명 복습인데 왜 이렇게 안 풀리지