Maximum Swap Leetcode Javascript Question