Next Permutation (LeetCode 31).
Asked in the onsite stage. Given an array of integers nums, rearrange it in place into its next lexicographically greater permutation. If no greater permutation exists, rearrange it into ascending order. Return the modified array for testability.
def next_permutation(nums):