Reverse an array, up to a a point

Question

Suppose you're given an array, a, as well as a position, p. Write a function to reverse your array, but only up to the position given in p. The rest of your array should remain untouched.

For example, given the following:

a = [1, 3, 4, 6]
p = 2

Your function should return:

[3,1,4,6]

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now