← Back
00:00

Binary Step Reduction

Two Sigma interview questions · Medium · Coding round · 6 tests

Start from a positive integer n. Each move lets you either increase or decrease the current value by some power of two (such as 1, 2, 4, 8, 16, ...). Going below zero along the way is permitted. Find the fewest moves that bring the value to exactly 0.

Idle