๋ฌธ์ ๐ฝ
https://school.programmers.co.kr/learn/courses/30/lessons/64065
๋ค๋ฅธ์ฌ๋ ํ์ด ๐ฝ
const tupleFrom = (str) =>
str.slice(2, -2).split('},{')
.map((it) => toNumbers(it))
.sort(accendingByLength)
.reduce((acc, cur) =>
[...acc, ...cur.filter((it) => !acc.includes(it))], []);
const toNumbers = (str) => str.split(',').map(it => Number(it));
const accendingByLength = (arr1, arr2) => arr1.length - arr2.length;
const solution = (s) => tupleFrom(s);
๋ดํ์ด๐ฝ
1. ์ฑ๊ณต โญ
function solution(s) {
var answer = [];
let arr = s.replaceAll("{{","").replaceAll("}}","").split("},{")
let arr2=[]
arr.forEach((value)=>{
arr2.push(value.split(","))
})
arr2.sort((a,b)=>{
return a.length-b.length
})
arr2.forEach((value,index)=>{
value.forEach((ele)=>{
if(!answer.includes(Number(ele))){
answer.push(Number(ele))
}
})
})
return answer;
}
๋๋์ ๐ฝ
์๋ฃํ์ ์๋ณด์ ...