Please read the new rule regarding the restriction on the use of AI tools. ×

Dare2Compete coding challenge question. HELP???

Revision en2, by basantCoder, 2021-09-20 10:51:40

You start with 0 and you have to Find the minimum number of operations to reach 'n'. In one operation you can add or subtract any 2^k to your current number. Where k can be any positive integer.
Constraints:
test cases <200,000;
1 <= | n | <= 1,000,000,000 . Example:
INPUT:
First line is no. of test cases, then a single integer 'n' on each line.
5
1
2
0
6
10
OUTPUT:
1
1
0
2
2
Can anybody help??

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English basantCoder 2021-09-20 10:51:40 170 Tiny change: '\nExample:\n\nINPUT: \n\nFirst li' -> '\nExample:<br>\nINPUT: <br>\nFirst li'
en1 English basantCoder 2021-09-20 10:42:09 396 Initial revision (published)