CodingReported in a candidate post, Aug 2017
Count set bits and return positions in array
Filed under Veritas
The question
Given a decimal number, count the number of set bits (1s) in its binary representation and return an array where the first element is the count and the remaining elements are the positions of the set bits from MSB to LSB.
No write-up yet. Related questions below have one.
Related Veritas questions
Collected from public candidate posts and coding forums. Updated Nov 2026.