Problem 397 · Medium

Integer Replacement

Find minimum steps to reach 1 from n using division by 2 (if even) or add/subtract 1 (if odd).

Open the interactive visualisation