We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 80259e4 commit c21dafbCopy full SHA for c21dafb
Easy/Sum of Values at Indices With K Set Bits.java
@@ -0,0 +1,8 @@
1
+class Solution {
2
+ public int sumIndicesWithKSetBits(List<Integer> nums, int k) {
3
+ return IntStream.range(0, nums.size())
4
+ .filter(idx -> Integer.bitCount(idx) == k)
5
+ .map(idx -> nums.get(idx))
6
+ .sum();
7
+ }
8
+}
0 commit comments