Skip to content
Merged
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
13 changes: 13 additions & 0 deletions reverse-bits/robinyoon-dev.js
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Bit Manipulation
  • 설명: 이 코드는 비트 연산을 활용하여 정수의 이진수 비트를 뒤집는 방식으로, 비트 조작 기법이 핵심인 패턴에 속합니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @param {number} n
* @return {number}
*/
var reverseBits = function(n) {
let result = 0;
for(let i = 0; i < 32; i++){
result = result << 1;
result = result | (n & 1);
Comment on lines +8 to +9
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

result <<= 1;
result |= (n & 1);

축약 연산자를 쓰면 비트 연산 의도가 더 잘보일 수 있을 것 같아요!
한 주 고생많으셨습니다! 👍

n = n >>> 1;
}
return result;
};
Loading