Search
⌘K

Leetcode 2859. Sum of Values at Indices With K Set Bits

Return the sum of elements nums[i] for all indices i whose binary representation contains exactly k set bits (i.e., popcount(i) == k). Constraints are small (n ≤ 1000, k ≤ 10), so check each index’s bit-count and accumulate.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.