1 Star 0 Fork 0

Roderland/algorithm

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
Question762.java 433 Bytes
Copy Edit Raw Blame History
Roderland authored 2021-03-19 00:37 +08:00 . ====== roderland ======
package question;
import java.util.Arrays;
import java.util.HashSet;
/**
* @author Roderland
* @since 1.0
*/
public class Question762 {
public int countPrimeSetBits(int L, int R) {
HashSet<Integer> set = new HashSet<>(Arrays.asList(2, 3, 5, 7, 11, 13, 17, 19));
int res=0;
for (int i = L; i <= R; i++) {
if (set.contains(Integer.bitCount(i))) res++;
}
return res;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/Roderland/algorithm.git
git@gitee.com:Roderland/algorithm.git
Roderland
algorithm
algorithm
master

Search