Maximum Swap Leetcode Problems Javascript