Next Greater Permutation Leetcode Solution Python