Minimum Operations to Reduce an Integer to 0

Asked at Salesforce · Coding Questions · Difficulty: Medium · Last asked Apr 3, 2026

Given a non-negative integer `n`, you may repeatedly change it by adding or subtracting a power of 2. Return the minimum number of such operations needed to make the value exactly 0.

Loading the problem…