a permutation array integer arrangement member sequence linear orderfor example arr 123 follow permutation arr 123 132 2 1 3 2 3 1 312 321the permutation array integer lexicographically great permutation integer more formally permutation array sort container accord lexicographical order permutation array permutation follow sorted container if arrangement possible array rearrange low possible order ie sort ascending orderfor example permutation arr 123 132similarly permutation arr 231 312while permutation arr 321 123 321 lexicographical large rearrangementGiven array integer num find permutation numsthe replacement place use constant extra memory Example 1input num 123output 132example 2input num 321output 123Example 3input num 115Output 151 Constraints1 numslength 1000 numsi 100