Previous Permutation With One Swap
Find the largest arrangement that is lexicographically smaller than the given one using at most one swap. The scan finds the rightmost place where a smaller digit can be swapped in.
Find the largest arrangement that is lexicographically smaller than the given one using at most one swap. The scan finds the rightmost place where a smaller digit can be swapped in.