Maximum Swap Leetcode Javascript Practice