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 ebf7aa8 commit 4b16de2Copy full SHA for 4b16de2
2501-3000/2859.py
@@ -0,0 +1,7 @@
1
+class Solution:
2
+ def sumIndicesWithKSetBits(self, nums: List[int], k: int) -> int:
3
+ res = 0
4
+ for i in range(len(nums)):
5
+ if str(bin(i)).count("1")==k:
6
+ res+=nums[i]
7
+ return res
0 commit comments