0762. Prime Number of Set Bits in Binary Representation
https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation
Description
Given two integers left
and right
, return the count of numbers in the inclusive range [left, right]
having a prime number of set bits in their binary representation.
Recall that the number of set bits an integer has is the number of 1
's present when written in binary.
For example,
21
written in binary is10101
which has3
set bits.
Example 1:
Example 2:
Constraints:
1 <= left <= right <= 106
0 <= right - left <= 104
ac
Last updated