https://school.programmers.co.kr/learn/courses/30/lessons/64065
function solution(s) {
var answer = [];
let strArr= s.replace("{{", "").replace("}}", "").split("},{"); //1.
let sortArr = [];
for (let i = 0; i < strArr.length; i++) {
sortArr.push(strArr[i].split(",")); //2.
}
sortArr.sort((a, b) => {
return a.length-b.length;
}); //3.
answer.push(+(sortArr[0][0])); //4.
for (let i = 1; i < sortArr.length; i++) {
sortArr[i].forEach((e) => {
if (!answer.includes(+e)){
answer.push(+e);
}//5.
})
}
return answer;
}