Next Permutation II(LintCode 190):

Problem