Skip to content
Open
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
12 changes: 12 additions & 0 deletions sik9252/다음_큰_숫자.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function solution(n) {
const countOne = (num) => num.toString(2).split("1").length - 1;
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.

-1은 없어도 되는 부분인 것 같아 보여요!

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.

깔끔하네요! 👍


const target = countOne(n);
let next = n + 1;

while (countOne(next) !== target) {
next++;
}

return next;
}
22 changes: 22 additions & 0 deletions sik9252/숫자의_표현.js
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.

Charlie Puth - Left Right Left 가 생각나네요

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function solution(n) {
let answer = 0;
let left = 1;
let right = 1;
let sum = 1;

while (left <= n) {
if (sum === n) {
answer++;
sum -= left;
left++;
} else if (sum < n) {
right++;
sum += right;
} else {
sum -= left;
left++;
}
}

return answer;
}
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.

지현님 풀이 참고해서 공부해봐야겠네요 !!

Loading