Next Permutation Problem Leetcode Javascript