Leetcode 397. Integer Replacement
Given a positive integer n, repeatedly apply n/2 if n is even or either n+1 or nā1 if n is odd and return the minimum number of moves to reach 1. The core challenge is choosing the optimal increment vs decrement for odd n (often solved with bit-manipulation/greedy or BFS/DP), with inputs up to 2^31ā1.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.