← Questions

Fewest powers of two to add or subtract to reach zero

0
UberCodingLast asked Feb 2026

Given a positive integer n, one operation adds or subtracts any power of two. Return the fewest operations that bring n to 0.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding