2859. Sum of Values at Indices With K Set Bits
You are given a 0-indexed integer array
numsand an integerk.Return an integer that denotes the sum of elements in
numswhose corresponding indices have exactlykset bits in their binary representation.The set bits in an integer are the
1‘s present when it is written in binary.
- For example, the binary representation of
21is10101, which has3set bits.
1 | class Solution { |