Skip to content

Commit ece1901

Browse files
committed
leetcode 190
1 parent 8e14d8d commit ece1901

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

LeetCode/190.Reverse Bits.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
typedef long long ll;
6+
const ll INF = 1e18;
7+
const ll mod1 = 1e9 + 7;
8+
const ll mod2 = 998244353;
9+
// Add main code here
10+
11+
class Solution
12+
{
13+
14+
public:
15+
uint32_t reverseBits(uint32_t n)
16+
{
17+
uint32_t x = 0;
18+
int d = 0;
19+
while (n > 0)
20+
{
21+
x += (n % 2) << (31 - d);
22+
n >>= 1;
23+
d++;
24+
}
25+
return x;
26+
}
27+
};

0 commit comments

Comments
 (0)