Skip to content

Commit 0eaa3a4

Browse files
authored
Merge pull request #1180 from ivan1016017/february11
adding reverse bit
2 parents 2db5645 + be063d8 commit 0eaa3a4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from typing import List, Union, Collection, Mapping, Optional
2+
from abc import ABC, abstractmethod
3+
4+
class Solution:
5+
def reverseBits(self, n: int) -> int:
6+
return int((('{0:032b}'.format(n))[::-1]),2)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import unittest
2+
from src.my_project.interviews.top_150_questions_round_13\
3+
.reverse_bits import Solution
4+
5+
class ReverseBitsTestCase(unittest.TestCase):
6+
7+
def test_reverse_bits(self):
8+
solution = Solution()
9+
output = solution.reverseBits(2)
10+
target = 1073741824
11+
self.assertEqual(output, target)

0 commit comments

Comments
 (0)