CSES - Permutations

I have a question about the CSES Permutations problem.


A permutation of integers 1,2,…,n is called beautiful if there are no adjacent elements whose difference is 1.

Given n, construct a beautiful permutation if such a permutation exists.

I have tried to write some permutations down and find a pattern, but I had no idea, Someone please give me a clue of how to solve this problem.

@Anny_Niu For big enough n, you’ll find that there is always a solution, try thinking of a simple way to always construct such a permutation. For example, a simple permutation for n = 5 would be 1 3 5 2 4… Think about when such a pattern would break(most likely for very small n).