Next Permutation Generator
Given an integer array arg1, return the arrangement of its values that comes immediately after arg1 in lexicographic order.
Two arrangements are compared element by element from the left, and the first position where they differ decides which one is larger. The answer is the smallest arrangement that is strictly larger than arg1. If arg1 is already the largest arrangement of its values, there is nothing larger, so the answer wraps around to the smallest arrangement: the same values sorted ascending. The empty array is returned unchanged.
Return the answer as an array, and use exactly the original elements. Duplicate values are allowed and every copy must be preserved; duplicates simply reduce how many distinct arrangements exist. Reordering arg1 in place and returning it is allowed, and the returned array is what gets graded.
Next Permutation Generator
Given an integer array `arg1`, return the arrangement of its values that comes immediately after `arg1` in lexicographic order.