Small Permutation Problem Leetcode