Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.