We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8899928 commit 5cc8f5cCopy full SHA for 5cc8f5c
1 file changed
src/Do-ho/implementation/pgs_튜플/pgs_tuple.js
@@ -0,0 +1,25 @@
1
+const removeBracket = s => {
2
+ const re = /[0-9]+(,[0-9]+)*/g;
3
+ return s.match(re);
4
+}
5
+
6
+const compareFunction = (prev, curr) => prev.length - curr.length;
7
8
+const parseStr = s => {
9
+ const strWithOutBracket = removeBracket(s);
10
+ const parsed = strWithOutBracket.reduce((acc, cur) => {
11
+ acc.push(cur.split(','));
12
+ return acc;
13
+ }, [])
14
+ return parsed.sort(compareFunction);
15
16
17
+const solution = s => {
18
+ const parsedArr = parseStr(s);
19
+ const answer = parsedArr.reduce((acc, cur) => {
20
+ const filterItem = cur.filter((item) => !acc.includes(item));
21
+ acc.push(filterItem[0]);
22
23
+ }, []).map(item => parseInt(item))
24
+ return answer;
25
0 commit comments