Skip to content

Commit

Permalink
Merge pull request #598 from gitsunmin/main
Browse files Browse the repository at this point in the history
[gitsunmin] WEEK 14 Solutions
  • Loading branch information
SamTheKorean authored Nov 17, 2024
2 parents 145a5b0 + 75b57dc commit eef72f2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions reverse-bits/gitsunmin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* https://leetcode.com/problems/reverse-bits/
* time complexity : O(1)
* space complexity : O(1)
*/

function reverseBits(n: number): number {
let result = 0;
for (let i = 0; i < 32; i++) {
result <<= 1;
result |= n & 1;
n >>>= 1;
}
return result >>> 0;
};

0 comments on commit eef72f2

Please sign in to comment.