values (0-indexed) and an integer ones. Write each index in binary and count its one bits.
Return the sum of the elements whose index has exactly ones one bits in binary.values=[7, 2, 9, 4, 1, 6], ones=2 → 10
The indices in binary are 0, 1, 10, 11, 100, 101. Indices 3 (11) and 5 (101) have two ones: 4 + 6 = 10.
values=[8, 3, 5], ones=0 → 8
Only index 0 has zero ones, so the answer is 8.
values=[7, 2, 9, 4, 1, 6], ones=2
10
Run checks the first 3 tests in your browser. Submit checks all 72 tests on the server, hidden ones included.