Lexicographically minimal permutation?

I was doing a problem from codeforces where i was asked to find out lexicographically minimal permutation.

Problem link: Problem - 1315C - Codeforces

What is the meaning of this term?

It’s like alphabetical order.
123 is smaller than 213 because 1 is smaller than 2.
213 is smaller than 231 because 1 is smaller than 3.

1 Like

But why there is no lexicographical minimal permutation possible if we take 2,3,4,5.
We can print 2,6,3,7,4,8,5,9.

You are not allowed to use 9. It must be a permutation of 1 2 3 4 5 6 7 8.

1 Like

Yeah i got it.
Thank you.