Maximum Swap Leetcode Javascript