Shift an array without wrapping in O(1) time

Viewed 22

I need to shift an array to the right without wrapping, for example:

[1,2,3,4,5,6,7,8,9]

after being right shifted by 2 becomes

[0,0,1,2,3,4,5,6,7]

This is simple to do with iteration, but would it be conceivable to do this operation in constant time?

If not, what would be the most efficient way to do this with a large array?

0 Answers
Related