Skip to content

Commit d82c231

Browse files
Update 2859.py
1 parent 4b16de2 commit d82c231

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

2501-3000/2859.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ def sumIndicesWithKSetBits(self, nums: List[int], k: int) -> int:
55
if str(bin(i)).count("1")==k:
66
res+=nums[i]
77
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

Comments
 (0)