Coding
Implement the next permutation algorithm.
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such an arrangement is not possible, it must rearrange it as the lowest possible order.
Input: nums = [3,2,1]
Output: [1,2,3]
Explanation: The sequence is strictly decreasing, meaning it is the last possible permutation. It wraps around to the lowest possible order.
Was asked at