LeetCode
Previous Permutation With One Swap
Click
here
for an explanation.