Banana-Leopard/TASTY huggingface dataset:
# Python program to split array and move first
# part to end.
 
def splitArr(arr, n, k):
    for i in range(0, k):
        x = arr[0]
        for j in range(0, n-1):
            arr[j] = arr[j + 1]
         
        arr[n-1] = x
         
 
# main
arr = [12, 10, 5, 6, 52, 36]
n = len(arr)
position = 2
 
splitArr(arr, n, position)
 
for i in range(0, n):
    print(arr[i], end = ' ')
 
# Code Contributed by Mohit Gupta_OMG <(0_o)>  

Time complexity: quadratic
Space complexity: constant
# Python3 program to split array and
# move first part to end.
 
# Function to split array and
# move first part to end
def SplitAndAdd(A, length, rotation):
 
    # make a temporary array with double
    # the size and each index is initialized to 0
    tmp = [ 0 for i in range(length * 2)]
 
    # copy array element in to new array twice
    for i in range(length):
        tmp[i] = A[i]
        tmp[i + length] = A[i]
 
    for i in range(rotation,
                   rotation + length, 1):
        A[i - rotation] = tmp[i];
      
# Driver code
arr = [12, 10, 5, 6, 52, 36]
n = len(arr)
position = 2
SplitAndAdd(arr, n, position);
for i in range(n):
    print(arr[i], end = " ")
print()
 
# This code is contributed by SOUMYA SEN

Time complexity: linear
Space complexity: linear
# Python3 program for above approach
 
# Function to transform the array
def fixArray(ar, n):
     
    # Iterate over the array
    for i in range(n):
        for j in range(n):
 
            # Check is any ar[j]
            # exists such that
            # ar[j] is equal to i
            if (ar[j] == i):
                ar[j], ar[i] = ar[i], ar[j]
 
    # Iterate over array
    for i in range(n):
         
        # If not present
        if (ar[i] != i):
            ar[i] = -1
 
    # Print the output
    print("Array after Rearranging")
 
    for i in range(n):
        print(ar[i], end = " ")
 
# Driver Code
ar = [ -1, -1, 6, 1, 9, 3, 2, -1, 4, -1 ]
n = len(ar)
 
# Function Call
fixArray(ar, n);
 
# This code is contributed by rag2127

Time complexity: quadratic
Space complexity: constant
# Python3 program for rearrange an
# array such that arr[i] = i.
 
# Function to rearrange an array
# such that arr[i] = i.
 
 
def fix(A, len):
 
    for i in range(0, len):
 
        if (A[i] != -1 and A[i] != i):
            x = A[i]
 
            # check if desired place
            # is not vacate
            while (A[x] != -1 and A[x] != x):
                 
                # store the value from
                # desired place
                y = A[x]
 
                # place the x to its correct
                # position
                A[x] = x
 
                # now y will become x, now
                # search the place for x
                x = y
 
            # place the x to its correct
            # position
            A[x] = x
 
            # check if while loop hasn't
            # set the correct value at A[i]
            if (A[i] != i):
 
                # if not then put -1 at
                # the vacated place
                A[i] = -1
 
 
# Driver code
A = [-1, -1, 6, 1, 9, 3, 2, -1, 4, -1]
 
fix(A, len(A))
 
for i in range(0, len(A)):
    print(A[i], end=' ')
 
# This code is contributed by Saloni1297

Time complexity: linear
Space complexity: constant
# Python3 program for rearrange an
# array such that arr[i] = i.
 
# Function to rearrange an array
# such that arr[i] = i.
def fix(A):
    s = set()
     
    # Storing all the values in the Set
    for i in range(len(A)):
        s.add(A[i])
 
    for i in range(len(A)):
       
        # check for item if present in set
        if i in s:
            A[i] = i
        else:
            A[i] = -1
    return A
     
# Driver code
if __name__ == "__main__":
    A = [-1, -1, 6, 1, 9,
          3, 2, -1, 4,-1]
    print(fix(A))
 
# This code is contributed by Chitranayal

Time complexity: linear
Space complexity: linear
# Python3 program for rearrange an
# array such that arr[i] = i.
if __name__ == "__main__":
 
    arr = [-1, -1, 6, 1, 9,
           3, 2, -1, 4, -1]
    n = len(arr)
    i = 0
    while i < n:
 
        if (arr[i] >= 0 and arr[i] != i):
            (arr[arr[i]],
             arr[i]) = (arr[i],
                        arr[arr[i]])
        else:
            i += 1
 
    for i in range(n):
        print(arr[i], end=" ")
 
# This code is contributed by Chitranayal

Time complexity: linear
Space complexity: constant
#  Python program to put positive numbers at even indexes (0,  // 2, 4,..) and
#  negative numbers at odd indexes (1, 3, 5, ..)
 
# The main function that rearranges elements of given array.
# It puts  positive elements at even indexes (0, 2, ..) and
# negative numbers at odd indexes (1, 3, ..).
def rearrange(arr, n):
    # The following few lines are similar to partition process
    # of QuickSort.  The idea is to consider 0 as pivot and
    # divide the array around it.
    i = -1
    for j in range(n):
        if (arr[j] < 0):
            i += 1
            # swapping of arr
            arr[i], arr[j] = arr[j], arr[i]
  
    # Now all positive numbers are at end and negative numbers
    # at the beginning of array. Initialize indexes for starting
    # point of positive and negative numbers to be swapped
    pos, neg = i+1, 0
  
    # Increment the negative index by 2 and positive index by 1,
    # i.e., swap every alternate negative number with next
    # positive number
    while (pos < n and neg < pos and arr[neg] < 0):
 
        # swapping of arr
        arr[neg], arr[pos] = arr[pos], arr[neg]
        pos += 1
        neg += 2
 
# A utility function to print an array
def printArray(arr, n):
     
    for i in range(n):
        print (arr[i],end=" ")
  
# Driver program to test above functions
arr = [-1, 2, -3, 4, 5, 6, -7, 8, 9]
n = len(arr)
rearrange(arr, n)
printArray(arr, n)
 
# Contributed by Afzal

Time complexity: linear
Space complexity: constant
# Python3 program to rearrange
# positive and negative integers
# in alternate fashion and
# maintaining the order of positive
# and negative numbers
 
# rotates the array to right by once
# from index 'outOfPlace to cur'
 
 
def rightRotate(arr, n, outOfPlace, cur):
    temp = arr[cur]
    for i in range(cur, outOfPlace, -1):
        arr[i] = arr[i - 1]
    arr[outOfPlace] = temp
    return arr
 
 
def rearrange(arr, n):
    outOfPlace = -1
    for index in range(n):
        if(outOfPlace >= 0):
 
            # if element at outOfPlace place in
            # negative and if element at index
            # is positive we can rotate the
            # array to right or if element
            # at outOfPlace place in positive and
            # if element at index is negative we
            # can rotate the array to right
            if((arr[index] >= 0 and arr[outOfPlace] < 0) or
               (arr[index] < 0 and arr[outOfPlace] >= 0)):
                arr = rightRotate(arr, n, outOfPlace, index)
                if(index-outOfPlace > 2):
                    outOfPlace += 2
                else:
                    outOfPlace = - 1
 
        if(outOfPlace == -1):
 
            # conditions for A[index] to
            # be in out of place
            if((arr[index] >= 0 and index % 2 == 0) or
               (arr[index] < 0 and index % 2 == 1)):
                outOfPlace = index
    return arr
 
 
# Driver Code
arr = [-5, -2, 5, 2, 4,
       7, 1, 8, 0, -8]
 
print("Given Array is:")
print(arr)
 
print("\nRearranged array is:")
print(rearrange(arr, len(arr)))
 
# This code is contributed
# by Charan Sai

Time complexity: quadratic
Space complexity: constant
# Python implementation to move all zeroes at
# the end of array
 
# function to move all zeroes at
# the end of array
def moveZerosToEnd (arr, n):
 
    # Count of non-zero elements
    count = 0;
 
 
    # Traverse the array. If arr[i] is non-zero, then
    # update the value of arr at index count to arr[i]
    for i in range(0, n):
        if (arr[i] != 0):
            arr[count] = arr[i]
            count+=1
    
    # Update all elements at index >=count with value 0
    for i in range(count, n):
        arr[i] = 0
 
 
 
# function to print the array elements
def printArray(arr, n):
 
    for i in range(0, n):
        print(arr[i],end=" ")
 
 
# Driver program to test above
arr = [ 0, 1, 9, 8, 4, 0, 0, 2,
    7, 0, 6, 0, 9 ]
n = len(arr)
 
print("Original array:", end=" ")
printArray(arr, n)
 
moveZerosToEnd(arr, n)
 
print("\nModified array: ", end=" ")
printArray(arr, n)
 
# This code is contributed by
# Ashutosh Singh

Time complexity: linear
Space complexity: constant
# Python3 program to find
# minimum swaps required
# to club all elements less
# than or equals to k together
 
# Utility function to find
# minimum swaps required to
# club all elements less than
# or equals to k together
def minSwap(arr, n, k) :
     
    # Find count of elements
    # which are less than
    # equals to k
    count = 0
    for i in range(0, n) :
        if (arr[i] <= k) :
            count = count + 1
     
    # Find unwanted elements
    # in current window of
    # size 'count'
    bad = 0
    for i in range(0, count) :
        if (arr[i] > k) :
            bad = bad + 1
     
    # Initialize answer with
    # 'bad' value of current
    # window
    ans = bad
    j = count
    for i in range(0, n) :
         
        if(j == n) :
            break
             
        # Decrement count of
        # previous window
        if (arr[i] > k) :
            bad = bad - 1
         
        # Increment count of
        # current window
        if (arr[j] > k) :
            bad = bad + 1
         
        # Update ans if count
        # of 'bad' is less in
        # current window
        ans = min(ans, bad)
 
        j = j + 1
 
    return ans
 
# Driver code
arr = [2, 1, 5, 6, 3]
n = len(arr)
k = 3
print (minSwap(arr, n, k))
 
arr1 = [2, 7, 9, 5, 8, 7, 4]
n = len(arr1)
k = 5
print (minSwap(arr1, n, k))
 
# This code is contributed by
# Manish Shaw(manishshaw1)

Time complexity: linear
Space complexity: constant
import sys
import math
 
 
class GFG :
   
    # Function for finding the minimum number of swaps
    # required to bring all the numbers less
    # than or equal to k together.
    @staticmethod
    def  minSwap( arr,  n,  k) :
       
        # Initially snowBallsize is 0
        snowBallSize = 0
        i = 0
        while (i < n) :
           
            # Calculating the size of window required
            if (arr[i] <= k) :
                snowBallSize += 1
            i += 1
        swap = 0
        ans_swaps = sys.maxsize
        i = 0
        while (i < snowBallSize) :
            if (arr[i] > k) :
                swap += 1
            i += 1
        ans_swaps = min(ans_swaps,swap)
        i = snowBallSize
        while (i < n) :
           
            # Checking in every window no. of swaps
            # required and storing its minimum
            if (arr[i - snowBallSize] <= k and arr[i] > k) :
                swap += 1
            elif(arr[i - snowBallSize] > k and arr[i] <= k) :
                swap -= 1
            ans_swaps = min(ans_swaps,swap)
            i += 1
        return ans_swaps
    @staticmethod
    def main( args) :
        arr1 = [2, 7, 9, 5, 8, 7, 4]
        n = len(arr1)
        k = 5
        print(GFG.minSwap(arr1, n, k))
     
if __name__=="__main__":
    GFG.main([])
     
    # This code is contributed by aadityaburujwale.

Time complexity: linear
Space complexity: constant
# Python 3 program to print
# the array in given order
 
# Function which arrange the
# array.
def rearrangeArray(arr, n) :
 
    # Sorting the array elements
    arr.sort()
 
    # To store modified array
    tempArr = [0] * (n + 1)
 
    # Adding numbers from sorted
    # array to new array accordingly
    ArrIndex = 0
 
    # Traverse from begin and end
    # simultaneously
    i = 0
    j = n-1
     
    while(i <= n // 2 or j > n // 2 ) :
     
        tempArr[ArrIndex] = arr[i]
        ArrIndex = ArrIndex + 1
        tempArr[ArrIndex] = arr[j]
        ArrIndex = ArrIndex + 1
        i = i + 1
        j = j - 1
     
    # Modifying original array
    for i in range(0, n) :
        arr[i] = tempArr[i]
         
 
# Driver Code
arr = [ 5, 8, 1, 4, 2, 9, 3, 7, 6 ]
n = len(arr)
rearrangeArray(arr, n)
 
for i in range(0, n) :
    print( arr[i], end = " ")
     
# This code is contributed by Nikita Tiwari.

Time complexity: nlogn
Space complexity: linear
# Python 3 program for
# moving negative numbers to left
# while maintaining the order
 
 
class Solution:
    def rotateSubArray(self, arr, l, r):
        temp = arr[r]
        for j in range(r, l-1, -1):
            arr[j] = arr[j-1]
        arr[l] = temp
 
        return arr
 
    def moveNegative(self, arr):
 
        last_negative_index = -1
 
        for i in range(len(arr)):
            if arr[i] < 0:
                last_negative_index += 1
                arr[i], arr[last_negative_index] = arr[last_negative_index], arr[i]
 
                # Done to manage order too
                if i - last_negative_index >= 2:
                    self.rotateSubArray(arr, last_negative_index+1, i)
 
        return arr
 
 
#  Driver Code
if __name__ == '__main__':
    arr = [5, 5, -3, 4, -8, 0, -7, 3, -9, -3, 9, -2, 1]
    ob = Solution()
    ob.moveNegative(arr)
    for i in arr:
        print(i, end=' ')
    print()
 
# This code is contributed by Kapil Bansal(devkapilbansal)

Time complexity: quadratic
Space complexity: constant
<script>
 
// Python 3 program for
// moving negative numbers to left
// while maintaining the order
 
 
class Solution{
     
    rotateSubArray(arr, l, r){
        let temp = arr[r]
        for(let j = r;j > l-1;j--){
            arr[j] = arr[j-1]
        }
        arr[l] = temp
 
        return arr
    }
 
     
    moveNegative(arr){
 
        let last_negative_index = -1
 
        for(let i=0;i<arr.length;i++){
            if(arr[i] < 0){
                last_negative_index += 1
                let temp = arr[i];
                arr[i] = arr[last_negative_index];
                arr[last_negative_index] = temp;
 
                // Done to manage order too
                if(i - last_negative_index >= 2)
                    this.rotateSubArray(arr, last_negative_index+1, i)
            }
        }
 
        return arr
    }
}
 
 
//  Driver Code
 
let arr = [5, 5, -3, 4, -8, 0, -7, 3, -9, -3, 9, -2, 1]
let ob = new Solution()
ob.moveNegative(arr)
for(let i of arr){
    document.write(i,' ')
}
 
// This code is contributed by shinjanpatra
 
</script>

Time complexity: quadratic
Space complexity: constant
# Python 3 program to Rearrange positive
# and negative numbers in a array
 
# A utility function to print
# an array of size n
 
 
def printArray(arr, n):
    for i in range(n):
        print(arr[i], end=" ")
    print()
 
# Function to Rearrange positive
# and negative numbers in a array
 
 
def RearrangePosNeg(arr, n):
 
    for i in range(1, n):
        key = arr[i]
 
        # if current element is positive
        # do nothing
        if (key > 0):
            continue
 
        ''' if current element is negative,
        shift positive elements of arr[0..i-1],
        to one position to their right '''
        j = i - 1
        while (j >= 0 and arr[j] > 0):
            arr[j + 1] = arr[j]
            j = j - 1
 
        # Put negative element at its
        # right position
        arr[j + 1] = key
 
 
# Driver Code
if __name__ == "__main__":
    arr = [-12, 11, -13, -5,
           6, -7, 5, -3, -6]
    n = len(arr)
 
    RearrangePosNeg(arr, n)
    printArray(arr, n)
 
# This code is contributed
# by ChitraNayal

Time complexity: nlogn
Space complexity: linear
# Python3 program to Rearrange positive
# and negative numbers in a array
 
# Function to print an array
 
 
def printArray(A, size):
 
    for i in range(size):
        print(A[i], end=" ")
    print()
 
# Merges two subarrays of arr[].
# First subarray is arr[l..m]
# Second subarray is arr[m + 1..r]
 
 
def merge(arr, l, m, r):
    i, j, k = 0, 0, 0
    n1 = m - l + 1
    n2 = r - m
 
    # create temp arrays */
    L = [arr[l + i] for i in range(n1)]
    R = [arr[m + 1 + j] for j in range(n2)]
 
    # Merge the temp arrays back into arr[l..r]*/
    i = 0  # Initial index of first subarray
    j = 0  # Initial index of second subarray
    k = l  # Initial index of merged subarray
 
    # Note the order of appearance of elements
    # should be maintained - we copy elements
    # of left subarray first followed by that
    # of right subarray
 
    # copy negative elements of left subarray
    while (i < n1 and L[i] < 0):
        arr[k] = L[i]
        k += 1
        i += 1
 
    # copy negative elements of right subarray
    while (j < n2 and R[j] < 0):
        arr[k] = R[j]
        k += 1
        j += 1
 
    # copy positive elements of left subarray
    while (i < n1):
        arr[k] = L[i]
        k += 1
        i += 1
 
    # copy positive elements of right subarray
    while (j < n2):
        arr[k] = R[j]
        k += 1
        j += 1
 
# Function to Rearrange positive and
# negative numbers in a array
 
 
def RearrangePosNeg(arr, l, r):
 
    if(l < r):
 
        # Same as (l + r)/2, but avoids
        # overflow for large l and h
        m = l + (r - l) // 2
 
        # Sort first and second halves
        RearrangePosNeg(arr, l, m)
        RearrangePosNeg(arr, m + 1, r)
 
        merge(arr, l, m, r)
 
 
# Driver Code
arr = [-12, 11, -13, -5,
       6, -7, 5, -3, -6]
arr_size = len(arr)
 
RearrangePosNeg(arr, 0, arr_size - 1)
 
printArray(arr, arr_size)
 
# This code is contributed by
# mohit kumar 29

Time complexity: nlogn
Space complexity: logn
# Python3 program to Rearrange positive
# and negative numbers in an array
 
# Function to print an array
 
 
def printArray(A, size):
 
    for i in range(0, size):
        print(A[i], end=" ")
    print()
 
# Function to reverse an array. An array can
# be reversed in O(n) time and O(1) space.
 
 
def reverse(arr, l, r):
 
    if l < r:
 
        arr[l], arr[r] = arr[r], arr[l]
        l, r = l + 1, r - 1
        reverse(arr, l, r)
 
# Merges two subarrays of arr[].
# First subarray is arr[l..m]
# Second subarray is arr[m + 1..r]
 
 
def merge(arr, l, m, r):
 
    i = l  # Initial index of 1st subarray
    j = m + 1  # Initial index of IInd
 
    while i <= m and arr[i] < 0:
        i += 1
 
    # arr[i..m] is positive
 
    while j <= r and arr[j] < 0:
        j += 1
 
    # arr[j..r] is positive
 
    # reverse positive part of left
    # sub-array (arr[i..m])
    reverse(arr, i, m)
 
    # reverse negative part of right
    # sub-array (arr[m + 1..j-1])
    reverse(arr, m + 1, j - 1)
 
    # reverse arr[i..j-1]
    reverse(arr, i, j - 1)
 
# Function to Rearrange positive
# and negative numbers in a array
 
 
def RearrangePosNeg(arr, l, r):
 
    if l < r:
 
        # Same as (l + r)/2, but avoids
        # overflow for large l and h
        m = l + (r - l) // 2
 
        # Sort first and second halves
        RearrangePosNeg(arr, l, m)
        RearrangePosNeg(arr, m + 1, r)
 
        merge(arr, l, m, r)
 
 
# Driver Code
if __name__ == "__main__":
 
    arr = [-12, 11, -13, -5, 6, -7, 5, -3, -6]
    arr_size = len(arr)
 
    RearrangePosNeg(arr, 0, arr_size - 1)
 
    printArray(arr, arr_size)
 
# This code is contributed by Rituraj Jain

Time complexity: quadratic
Space complexity: linear
def rearrangePosNegWithOrder(arr, size):
    i = 0
    j = 0
    while(j < size):
        if(arr[j] >= 0):
            j += 1
        else:
            for k in range(j,i,-1):
                temp = arr[k]
                arr[k] = arr[k - 1]
                arr[k - 1] = temp  
            i += 1
            j += 1
    return arr
   
# driver code
arr = [-12, 11, -13, -5, 6, -7, 5, -3, -6 ]
size = len(arr)
aux = rearrangePosNegWithOrder(arr, size)
for i in aux:
    print(i,end=" ")
 
# This code is contributed by Vibhu Karnwal

Time complexity: linear
Space complexity: constant
# Python program to rearrange an array in minimum
# maximum form
 
# Prints max at first position, min at second position
# second max at third position, second min at fourth
# position and so on.
 
 
def rearrange(arr, n):
    # Auxiliary array to hold modified array
    temp = n*[None]
 
    # Indexes of smallest and largest elements
    # from remaining array.
    small, large = 0, n-1
 
    # To indicate whether we need to copy remaining
    # largest or remaining smallest at next position
    flag = True
 
    # Store result in temp[]
    for i in range(n):
        if flag is True:
            temp[i] = arr[large]
            large -= 1
        else:
            temp[i] = arr[small]
            small += 1
 
        flag = bool(1-flag)
 
    # Copy temp[] to arr[]
    for i in range(n):
        arr[i] = temp[i]
    return arr
 
 
# Driver code
arr = [1, 2, 3, 4, 5, 6]
n = len(arr)
print("Original Array")
print(arr)
print("Modified Array")
print(rearrange(arr, n))
 
# This code is contributed by Pratik Chhajer

Time complexity: linear
Space complexity: linear
# Python code for the same approach
def move(arr):
  arr.sort()
 
# driver code
arr = [ -1, 2, -3, 4, 5, 6, -7, 8, 9 ]
move(arr)
for e in arr:
    print(e , end = " ")
 
# This code is contributed by shinjanpatra

Time complexity: nlogn
Space complexity: linear
# A Python 3 program to put
# all negative numbers before
# positive numbers
 
def rearrange(arr, n ) :
 
    # Please refer partition() in
    # below post
    # https://www.geeksforgeeks.org / quick-sort / j = 0
    j = 0
    for i in range(0, n) :
        if (arr[i] < 0) :
            temp = arr[i]
            arr[i] = arr[j]
            arr[j]= temp
            j = j + 1
    print(arr)
 
# Driver code
arr = [-1, 2, -3, 4, 5, 6, -7, 8, 9]
n = len(arr)
rearrange(arr, n)
 
 
# This code is contributed by Nikita Tiwari.

Time complexity: linear
Space complexity: constant
# Python3 program of the
# above approach
 
# Function to shift all the
# the negative elements to
# the left of the array
def shiftall(arr,left,right):
   
  # Loop to iterate while the
  # left pointer is less than
  # the right pointer
  while left<=right:
     
    # Condition to check if the left
    # and right pointer negative
    if arr[left] < 0 and arr[right] < 0:
      left+=1
       
    # Condition to check if the left
    # pointer element is positive and
    # the right pointer element is
    # negative
    else if arr[left]>0 and arr[right]<0:
      arr[left], arr[right] = \
              arr[right],arr[left]
      left+=1
      right-=1
       
    # Condition to check if the left
    # pointer is positive and right
    # pointer as well
    else if arr[left]>0 and arr[right]>0:
      right-=1
    else:
      left+=1
      right-=1
       
# Function to print the array
def display(arr):
  for i in range(len(arr)):
    print(arr[i], end=" ")
  print()
 
# Driver Code
if __name__ == "__main__":
  arr=[-12, 11, -13, -5, \
       6, -7, 5, -3, 11]
  n=len(arr)
  shiftall(arr,0,n-1)
  display(arr)
 
# Sumit Singh

Time complexity: linear
Space complexity: constant
# Python code for the approach
 
# Using Dutch National Flag Algorithm.
def reArrange(arr, n):
    low,high = 0, n - 1
    while(low<high):
        if(arr[low] < 0):
            low += 1
        elif(arr[high] > 0):
            high -= 1
        else:
            arr[low],arr[high] = arr[high],arr[low]
 
def displayArray(arr, n):
 
    for i in range(n):
        print(arr[i],end = " ")
   
    print('')
 
# driver code
# Data
arr = [1, 2,  -4, -5, 2, -7, 3, 2, -6, -8, -9, 3, 2,  1]
n = len(arr)
reArrange(arr,n)
displayArray(arr,n)
 
# This code is contributed by shinjanpatra

Time complexity: linear
Space complexity: constant
# Python program to Move All -ve Element At End
# Without changing order Of Array Element
 
# Moves all -ve element to end of array in
# same order.
def move(arr,n):
    j = 0
    ans=[None]*n
    i=0;j=n-1
    for k in range(n):
        if arr[k]>=0:
          ans[i]=arr[k]
          i+=1
        else:
          ans[j]=arr[k]
          j-=1
    ans[i:]=ans[n-1:i-1:-1]
    return ans
 
# Driver program
arr = [1 ,-1 ,-3 , -2, 7, 5, 11, 6 ]
n = len(arr)
print(move(arr, n))
 
 
# Contributed by Venkatesh hegde

Time complexity: linear
Space complexity: linear