Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible ...
Given an array like nums = [1, 2, 3], the next permutation is [1, 3, 2]. If it's the last permutation like [3, 2, 1], then the next should be the smallest one: [1, 2, 3]. Steps: 1.Find the first index ...