2859. Sum of Values at Indices With K Set Bits Updated: 2024-03-12 1 min read Algorithms , LeetCode On This PageLeetCode problem 2859class Solution: def sumIndicesWithKSetBits(self, nums: List[int], k: int) -> int: return sum(x for i, x in enumerate(nums) if i.bit_count() == k)