Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions sik9252/이진_변환_반복하기.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function solution(s) {
let convertedCount = 0;
let zeroCount = 0;

while (s !== "1") {
const filtered = s.replace(/0/g, "");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaceAll로 0을 모두 제거하기보다 정규 표현식을 활용하는 방법도 좋네요!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 정규식 오랜만에 보네요!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 정규식 이거 귀합니다! ㅋㅋㅋ


zeroCount += s.length - filtered.length;
s = filtered.length.toString(2);
convertedCount++;
}

return [convertedCount, zeroCount];
}
12 changes: 12 additions & 0 deletions sik9252/최솟값_만들기.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function solution(A, B) {
let answer = 0;

A.sort((a, b) => a - b);
B.sort((a, b) => b - a);

for (let i = 0; i < A.length; i++) {
answer += A[i] * B[i];
}

return answer;
}
Loading