Permutations Leetcode Solution Python