Integer Replacement Leetcode Python