Skip to content

Commit 4b16de2

Browse files
Create 2859.py
1 parent ebf7aa8 commit 4b16de2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

2501-3000/2859.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)