Next Permutation Leetcode Solution Python