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

Автор hellomoto, история, 3 года назад, По-английски

As we know if we have an array of size n, let's say a0, a1, a2, ......, an-1. we can preform x move clockwise with ((ai + x) % n) and anticlockwise with ((ai — x) % n + n) % n.

Can we generalized for clockwise and anticlockwise for the index i to j (0 <= i, j < n)?

So what will be the formula if we want to move x (x can be greater than (j — i + 1)) steps in a circle from ai to aj (0 <= i, j < n) in an array (0 indexed and size of the array is n)?

Any help will be appreciated.

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

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by hellomoto (previous revision, new revision, compare).

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by hellomoto (previous revision, new revision, compare).

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by hellomoto (previous revision, new revision, compare).