Download 10-week-algorithm-excercise-master/Week_08/190/reverse_bits.py from Dorothydu/gitrepo_20: direct link, hf CLI and curl.
- Browser
- Download file 199 Bytes
-
https://huggingface.co/datasets/Dorothydu/gitrepo_20/resolve/main/10-week-algorithm-excercise-master/Week_08/190/reverse_bits.py
- Command line
-
hf download hf://datasets/Dorothydu/gitrepo_20/10-week-algorithm-excercise-master/Week_08/190/reverse_bits.py
-
curl -L -o reverse_bits.py https://huggingface.co/datasets/Dorothydu/gitrepo_20/resolve/main/10-week-algorithm-excercise-master/Week_08/190/reverse_bits.py
199 Bytes
| class Solution: | |
| def reverseBits(self, n: int) -> int: | |
| ans, pow = 0, 31 | |
| while n > 0: | |
| ans += (1 & n) << pow | |
| pow -= 1 | |
| n >>= 1 | |
| return ans | |