Skip to content

Commit 2e0edde

Browse files
author
Eric
committed
75차 3번 문제풀이
1 parent 9c2c11c commit 2e0edde

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

live7/test75/문제3/황장현.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function solution(s) {
2+
const temp = s
3+
.slice(2, -2)
4+
.split('},{')
5+
.map((s) => s.split(',').map(Number));
6+
7+
temp.sort((a, b) => a.length - b.length);
8+
9+
const result = [];
10+
const seen = new Set();
11+
12+
for (const arr of temp) {
13+
for (const num of arr) {
14+
if (!seen.has(num)) {
15+
result.push(num);
16+
seen.add(num);
17+
}
18+
}
19+
}
20+
21+
return result;
22+
}
23+
24+
console.log(solution('{{2},{2,1},{2,1,3},{2,1,3,4}}'));

0 commit comments

Comments
 (0)