Блог пользователя aurora_

Автор aurora_, история, 5 лет назад, По-английски

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 ]<---(+2), [ 4 ]<---(+1), [ 2 ]<---(-2), [ 1 ]<---(-1)

this is a valid arrangement.

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится