Integer Replacement Leetcode Javascript 30