Previous Permutation(LintCode 51):

Problem