Integer Replacement Leetcode Javascript Problems