Skip to content

Commit eed3619

Browse files
committed
76
1 parent 43f7050 commit eed3619

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

BIT/762.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Prime Number of Set Bits in Binary Representation
2+
3+
#### Description
4+
5+
[link](https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/description/)
6+
7+
---
8+
9+
#### Solution
10+
11+
- bin in python
12+
13+
---
14+
15+
#### Code
16+
17+
O(n)
18+
19+
```python
20+
class Solution:
21+
def countPrimeSetBits(self, L: int, R: int) -> int:
22+
primes = {2, 3, 5, 7, 11, 13, 17, 19}
23+
return sum(map(lambda x: bin(x).count('1') in primes, range(L, R+1)))
24+
```

0 commit comments

Comments
 (0)