An interesting (to me) sequence

Revision en2, by aurora_, 2019-06-27 22:15:12

Suppose, you have N consecutive numbers. You need to arrange them in such a way that, after arranging, subtraction between any two adjacent number will not be same. Numbers at index 1 and N will be considered adjacent. And also, you must put number 1 at index 1. For example, when N=4, [ 1 ] , 3 , 4 , 2 , 1

this is a valid arrangement.

Is there any approach to find a O(N * log N) solution? Thanks in advance.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English aurora_ 2019-06-27 22:16:36 20
en2 English aurora_ 2019-06-27 22:15:12 27
en1 English aurora_ 2019-06-27 22:13:11 462 Initial revision (published)