Solving Integer Replacement in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

Example 1:

Input:
8

Output:
3

Explanation:
8 -> 4 -> 2 -> 1

Example 2:

Input:
7

Output:
4

Explanation:
7 -> 8 -> 4 -> 2 -> 1
or
7 -> 6 -> 3 -> 2 -> 1

    15 -> 16 -> 8 -> 4 -> 2 -> 1
    15 -> 14 -> 7 -> 6 -> 3 -> 2 -> 1

    111011 -> 111010 -> 11101 -> 11100 -> 1110 -> 111 -> 1000 -> 100 -> 10 -> 1
    111011 -> 111100 -> 11110 -> 1111 -> 10000 -> 1000 -> 100 -> 10 -> 1

See the full details of the problem Integer Replacement at LeetCode

Originally posted at: @github.com/halfrost/LeetCode-Go