A permutation of an array of integers is an arrangement of its members into a sequence or linear order. The next permutation of an array is the next lexicographically greater permutation. If such arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted in ascending order).
Java
Next Permutation
A permutation of an array of integers is an arrangement of its members into a sequence or linear order. The next permutation of an array is the next lexicographically greater permutation. If such arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted in ascending order).
Example 1:
Input: [1,2,3]
Output: [1,3,2]
Input
arr =[1,2,3]
Initializing
Find the next lexicographically greater permutation of [1, 2, 3]