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
12 changes: 12 additions & 0 deletions reverse-bits/tedkimdev.rs
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
  • 설명: 이 코드는 비트 연산을 활용하여 32비트 정수의 비트 순서를 뒤집는 작업을 수행하므로 Bit Manipulation 패턴에 속합니다.

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.

깔끔하게 잘 푸신 것 같습니다👍

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// TC: O(1)
// SC: O(1)
impl Solution {
pub fn reverse_bits(n: u32) -> u32 {
let mut res: u32 = 0;
for i in 0..32 {
let bit = (n >> i) & 1;
res += bit << (31 - i);
}
res
}
}
Loading