Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
If <code>perm[0]</code> is <code>x</code>, there are at least <code>(x - 1) * (n - 1)!</code> permutations before <code>perm<c/ode>. (All the ones starting with numbers less than <code>x</code>)
Can you find out what happens for <code>perm[1]</code> onwards?
Think about the count of the numbers that can be in place of <code>perm[i]</code> and come before it.