LeetCode
Integer Replacement
Click
here
for an explanation.