
function solution(msg) {
var answer = [];
const indices = {}
for(let i=0; i<26; i++){
indices[String.fromCharCode(65 +i)] = i+1
}
let indiceSize = 26;
for(let i=0; i<msg.length; i++){
let acc = msg[i]
while(indices[acc + msg[i+1]]){
acc = acc + msg[i+1]
i++;
}
indiceSize++;
indices[acc+ msg[i+1]] = indiceSize
const indice = indices[acc]
answer.push(indice)
}
return answer;
}