Back to problems

Minimum Operations to Transform an Integer Using ±2^i Steps

Algorithm · Microsoft · Medium

You are given two integers, start and target. A single move lets you select any non-negative integer i, then increase the current number by 2^i or decrease it by 2^i. Every increase or decrease uses one move. Determine the fewest moves needed to change start into target. Input The input contains one line holding two integers: start target. Output Output one integer representing the smallest possible number of moves. Constraints -10^18 ≤ start, target ≤ 10^18 The exponent i…

Loading the rest of the question…