Sum at Set Bit Indices

Given an integer array nums and an integer k, sum the elements at indices whose binary representation contains exactly k set bits. A set bit is a bit with value 1. Return the resulting sum.

Examples
Input: [[5,10,1,5,2],1]
Output: 13
Hints

Sum at Set Bit Indices

Given an integer array nums and an integer k, sum the elements at indices whose binary representation contains exactly k set bits. A set bit is a bit with value 1. Return the resulting sum.