rewrite leetcode permutation sequence