Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5ac0dfb

Browse files
committed
refac: 숫자 짝궁 풀이 리팩토링
1 parent 39fd1a4 commit 5ac0dfb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎level-1/숫자짝꿍&131128&.js renamed to ‎level-1/숫자-짝꿍&131128&.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//더 좋은 풀이가 존재할 수 있습니다.
3+
//정답 1 - ssi02014
4+
15
/**
2-
* 풀이 - ssi02014
36
* X, Y의 길이가 굉장히 길어서 공통 숫자를 뽑아낼 때 객체를 이용해 연산 횟수 최적화
47
* X, Y를 배열로 변환 후에 배열 메서드를 사용해도 되지만, for of문보다 효율성 떨어짐
58
* (테스트 케이스 11 ~ 15 100ms~200ms 차이)
@@ -23,5 +26,5 @@ function solution(X, Y) {
2326

2427
if (!commons.length) return "-1";
2528
else if (commons[0] === "0") return "0";
26-
return commons.reduce((acc,cur)=>acc+cur,"");
29+
return commons.join("");
2730
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /