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
6 changes: 6 additions & 0 deletions doitchuu/MakeMinimumValue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function solution(A, B) {
const sortedA = A.sort((a, b) => a - b);
const sortedB = B.sort((a, b) => b - a);

return sortedA.reduce((acc, cur, index) => acc + (cur * sortedB[index]), 0);
}
17 changes: 17 additions & 0 deletions doitchuu/RepeatBinaryTransformation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function solution(s) {
if (s === "1") {
return [0, 0];
}

let count = 0;
let zeroCount = 0;

while (s !== "1") {
const length = s.replaceAll("0", "").length;
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.

오 바로 length를 주는 거 좋네요!

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

return [count, zeroCount];
}