2859. Sum of Values at Indices With K Set Bits

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2859

class Solution:
    def sumIndicesWithKSetBits(self, nums: List[int], k: int) -> int:
        return sum(x for i, x in enumerate(nums) if i.bit_count() == k)