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