Permutation Problem On Leetcode 150