Permutation Problem On Leetcode