Banana-Leopard/TASTY huggingface dataset:
// C++ program for rearrange an
// array such that arr[i] = i.
#include <iostream>
using namespace std;
 
void fixArray(int arr[], int n)
{
 
    int i = 0;
    while (i < n) {
        int correct = arr[i];
        if (arr[i] != -1 && arr[i] != arr[correct]) {
          // if array element should be lesser than
          // size and array element should not be at
          // its correct position then only swap with
          // its correct position or index value
            swap(arr[i], arr[correct]);
        }
        else {
          // if element is at its correct position
          // just increment i and check for remaining
          // array elements
            i++;
        }
    }
    return arr;
}
 
// Driver Code
int main()
{
    int arr[] = { -1, -1, 6, 1, 9, 3, 2, -1, 4, -1 };
    int n = sizeof(arr) / sizeof(arr[0]);
 
    // Function Call
    fixArray(arr, n);
 
    // Print output
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    return 0;
}
 
// This Code is Contributed by kothavvsaakash

Time complexity: linear
Space complexity: constant
// C++ program to rearrange the array as per the given
// condition
 
#include <bits/stdc++.h>
using namespace std;
 
// function to rearrange the array
void rearrangeArr(int arr[], int n)
{
    // total even positions
    int evenPos = n / 2;
    // total odd positions
    int oddPos = n - evenPos;
    int tempArr[n];
   
    // copy original array in an auxiliary array
    for (int i = 0; i < n; i++)
        tempArr[i] = arr[i];
 
    // sort the auxiliary array
    sort(tempArr, tempArr + n);
    int j = oddPos - 1;
 
    // fill up odd position in original array
    for (int i = 0; i < n; i += 2)
        arr[i] = tempArr[j--];
 
    j = oddPos;
 
    // fill up even positions in original array
    for (int i = 1; i < n; i += 2)
        arr[i] = tempArr[j++];
 
    // display array
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
}
 
// Driver code
int main()
{
    int arr[] = { 1, 2, 3, 4, 5, 6, 7 };
    int size = sizeof(arr) / sizeof(arr[0]);
    rearrangeArr(arr, size);
    return 0;
}

Time complexity: nlogn
Space complexity: linear
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n,i,p,q;
    int a[]= {1, 2, 1, 4, 5, 6, 8, 8};
    n=sizeof(a)/sizeof(a[0]);
    int b[n];
    for(i=0;i<n;i++)
        b[i]=a[i];
 
    sort(b,b+n);
    p=0;q=n-1;
    for(i=n-1;i>=0;i--){
            if(i%2!=0){
            a[i]=b[q];
            q--;
            }
            else{
                a[i]=b[p];
                p++;
            }
    }
    for(i=0;i<n;i++){
        cout<<a[i]<<" ";
    }
    return 0;
}

Time complexity: nlogn
Space complexity: linear
/*  C++ program to rearrange
   positive and negative integers
   in alternate fashion while keeping
   the order of positive and negative numbers. */
#include <assert.h>
#include <iostream>
using namespace std;
 
// Utility function to right rotate all elements between
// [outofplace, cur]
void rightrotate(int arr[], int n, int outofplace, int cur)
{
    char tmp = arr[cur];
    for (int i = cur; i > outofplace; i--)
        arr[i] = arr[i - 1];
    arr[outofplace] = tmp;
}
 
void rearrange(int arr[], int n)
{
    int outofplace = -1;
 
    for (int index = 0; index < n; index++) {
        if (outofplace >= 0) {
            // find the item which must be moved into the
            // out-of-place entry if out-of-place entry is
            // positive and current entry is negative OR if
            // out-of-place entry is negative and current
            // entry is negative then right rotate
            //
            // [...-3, -4, -5, 6...] -->   [...6, -3, -4,
            // -5...]
            //      ^                          ^
            //      |                          |
            //     outofplace      -->      outofplace
            //
            if (((arr[index] >= 0) && (arr[outofplace] < 0))
                || ((arr[index] < 0)
                    && (arr[outofplace] >= 0))) {
                rightrotate(arr, n, outofplace, index);
 
                // the new out-of-place entry is now 2 steps
                // ahead
                if (index - outofplace >= 2)
                    outofplace = outofplace + 2;
                else
                    outofplace = -1;
            }
        }
 
        // if no entry has been flagged out-of-place
        if (outofplace == -1) {
            // check if current entry is out-of-place
            if (((arr[index] >= 0) && (!(index & 0x01)))
                || ((arr[index] < 0) && (index & 0x01))) {
                outofplace = index;
            }
        }
    }
}
 
// A utility function to print an array 'arr[]' of size 'n'
void printArray(int arr[], int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << endl;
}
 
// Driver code
int main()
{
 
    int arr[] = { -5, -2, 5, 2, 4, 7, 1, 8, 0, -8 };
    int n = sizeof(arr) / sizeof(arr[0]);
 
    cout << "Given array is \n";
    printArray(arr, n);
 
    rearrange(arr, n);
 
    cout << "Rearranged array is \n";
    printArray(arr, n);
 
    return 0;
}

Time complexity: quadratic
Space complexity: constant
// C++ Program to move all zeros to the end
 
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A[] = { 5, 6, 0, 4, 6, 0, 9, 0, 8 };
    int n = sizeof(A) / sizeof(A[0]);
    int j = 0;
    for (int i = 0; i < n; i++) {
        if (A[i] != 0) {
            swap(A[j], A[i]); // Partitioning the array
            j++;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << A[i] << " "; // Print the array
    }
 
    return 0;
}

Time complexity: linear
Space complexity: constant
# C++ program to shift all zeros
# to right most side of array
# without affecting order of non-zero
# elements
 
# Given list
arr = [5, 6, 0, 4, 6, 0, 9, 0, 8]
 
# Storing all non zero values
nonZeroValues = [x for x in arr if x != 0]
 
# Storing all zeroes
zeroes = [j for j in arr if j == 0]
 
# Updating the answer
arr = nonZeroValues + zeroes
 
# Printing the answer
print( "array after shifting zeros to right side: " + arr)

Time complexity: linear
Space complexity: constant
// C++ implementation to move all zeroes at the end of array
#include <iostream>
using namespace std;
 
// function to move all zeroes at the end of array
void moveZerosToEnd(int arr[], int n)
{
    // Count of non-zero elements
    int count = 0;
 
    // Traverse the array. If arr[i] is non-zero, then
    // update the value of arr at index count to arr[i]
    for (int i = 0; i < n; i++)
        if (arr[i] != 0)
            arr[count++] = arr[i];
 
    // Update all elements at index >=count with value 0
    for (int i = count; i < n; i++)
        arr[i] = 0;
}
 
// function to print the array elements
void printArray(int arr[], int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
}
 
// Driver program to test above
int main()
{
    int arr[] = { 0, 1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0, 9 };
    int n = sizeof(arr) / sizeof(arr[0]);
 
    cout << "Original array: ";
    printArray(arr, n);
 
    moveZerosToEnd(arr, n);
 
    cout << "\nModified array: ";
    printArray(arr, n);
    return 0;
}

Time complexity: linear
Space complexity: constant
// C++ program to find minimum swaps required
// to club all elements less than or equals
// to k together
#include <iostream>
using namespace std;
 
// Utility function to find minimum swaps
// required to club all elements less than
// or equals to k together
int minSwap(int *arr, int n, int k) {
     
    // Find count of elements which are
    // less than equals to k
    int count = 0;
    for (int i = 0; i < n; ++i)
        if (arr[i] <= k)
            ++count;
     
    // Find unwanted elements in current
    // window of size 'count'
    int bad = 0;
    for (int i = 0; i < count; ++i)
        if (arr[i] > k)
            ++bad;
     
    // Initialize answer with 'bad' value of
    // current window
    int ans = bad;
    for (int i = 0, j = count; j < n; ++i, ++j) {
         
        // Decrement count of previous window
        if (arr[i] > k)
            --bad;
         
        // Increment count of current window
        if (arr[j] > k)
            ++bad;
         
        // Update ans if count of 'bad'
        // is less in current window
        ans = min(ans, bad);
    }
    return ans;
}
 
// Driver code
int main() {
     
    int arr[] = {2, 1, 5, 6, 3};
    int n = sizeof(arr) / sizeof(arr[0]);
    int k = 3;
    cout << minSwap(arr, n, k) << "\n";
     
    int arr1[] = {2, 7, 9, 5, 8, 7, 4};
    n = sizeof(arr1) / sizeof(arr1[0]);
    k = 5;
    cout << minSwap(arr1, n, k);
    return 0;
}

Time complexity: linear
Space complexity: constant
#include <bits/stdc++.h>
using namespace std;
 
// Function for finding the minimum number of swaps
// required to bring all the numbers less
// than or equal to k together. 
int minSwap(int arr[], int n, int k)
{
 
    // Initially snowBallsize is 0
    int snowBallSize = 0;
 
    for (int i = 0; i < n; i++) {
 
        // Calculating the size of window required
        if (arr[i] <= k) {
            snowBallSize++;
        }
    }
 
    int swap = 0, ans_swaps = INT_MAX;
 
    for (int i = 0; i < snowBallSize; i++) {
        if (arr[i] > k)
            swap++;
    }
 
    ans_swaps = min(ans_swaps, swap);
 
    for (int i = snowBallSize; i < n; i++) {
 
        // Checking in every window no. of swaps required
        // and storing its minimum
        if (arr[i - snowBallSize] <= k && arr[i] > k)
            swap++;
        else if (arr[i - snowBallSize] > k && arr[i] <= k)
            swap--;
        ans_swaps = min(ans_swaps, swap);
    }
    return ans_swaps;
}
 
// Driver's code
int main()
{
    int arr1[] = { 2, 7, 9, 5, 8, 7, 4 };
    int n = sizeof(arr1) / sizeof(arr1[0]);
    int k = 5;
    cout << minSwap(arr1, n, k) << "\n";
    return 0;
}
 
// This code is contributed by aditya942003patil

Time complexity: linear
Space complexity: constant
// C++ implementation of
// the above approach
#include <iostream>
 
void printArray(int array[], int length)
{
    std::cout << "[";
     
    for(int i = 0; i < length; i++)
    {
        std::cout << array[i];
         
        if(i < (length - 1))
            std::cout << ", ";
        else
            std::cout << "]" << std::endl;
    }
}
 
void reverse(int array[], int start, int end)
{
    while(start < end)
    {
        int temp = array[start];
        array[start] = array[end];
        array[end] = temp;
        start++;
        end--;
    }
}
 
// Rearrange the array with all negative integers
// on left and positive integers on right
// use recursion to split the array with first element
// as one half and the rest array as another and then
// merge it with head of the array in each step 
void rearrange(int array[], int start, int end)
{
    // exit condition
    if(start == end)
        return;
     
    // rearrange the array except the first
    // element in each recursive call
    rearrange(array, (start + 1), end);
     
    // If the first element of the array is positive,
    // then right-rotate the array by one place first
    // and then reverse the merged array.
    if(array[start] >= 0)
    {
        reverse(array, (start + 1), end);
        reverse(array, start, end);
    }
}
 
// Driver code
int main()
{
    int array[] = {-12, -11, -13, -5, -6, 7, 5, 3, 6};
    int length = (sizeof(array) / sizeof(array[0]));
    int countNegative = 0;
     
    for(int i = 0; i < length; i++)
    {
        if(array[i] < 0)
            countNegative++;
    }
     
    std::cout << "array: ";
    printArray(array, length);
    rearrange(array, 0, (length - 1));
     
    reverse(array, countNegative, (length - 1));
     
    std::cout << "rearranged array: ";
    printArray(array, length);
    return 0;
}

Time complexity: quadratic
Space complexity: quadratic
// C++ program to print the array in given order
#include <bits/stdc++.h>
using namespace std;
 
// Function which arrange the array.
void rearrangeArray(int arr[], int n)
{
    // Sorting the array elements
    sort(arr, arr + n);
 
    int tempArr[n]; // To store modified array
 
    // Adding numbers from sorted array to
    // new array accordingly
    int ArrIndex = 0;
 
    // Traverse from begin and end simultaneously
    for (int i = 0, j = n - 1; i <= n / 2 || j > n / 2;
         i++, j--) {
        tempArr[ArrIndex] = arr[i];
        ArrIndex++;
        tempArr[ArrIndex] = arr[j];
        ArrIndex++;
    }
 
    // Modifying original array
    for (int i = 0; i < n; i++)
        arr[i] = tempArr[i];
}
 
// Driver Code
int main()
{
    int arr[] = { 5, 8, 1, 4, 2, 9, 3, 7, 6 };
    int n = sizeof(arr) / sizeof(arr[0]);
    rearrangeArray(arr, n);
 
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
 
    return 0;
}

Time complexity: nlogn
Space complexity: linear
// C++ implementation to rearrange the array elements after
// modification
#include <bits/stdc++.h>
using namespace std;
 
// function which pushes all zeros to end of an array.
void pushZerosToEnd(int arr[], int n)
{
    // Count of non-zero elements
    int count = 0;
 
    // Traverse the array. If element encountered is
    // non-zero, then replace the element at  index 'count'
    // with this element
    for (int i = 0; i < n; i++)
        if (arr[i] != 0)
 
            // here count is incremented
            arr[count++] = arr[i];
 
    // Now all non-zero elements have been shifted to front
    // and 'count' is set as index of first 0. Make all
    // elements 0 from count to end.
    while (count < n)
        arr[count++] = 0;
}
 
// function to rearrange the array elements after
// modification
void modifyAndRearrangeArr(int arr[], int n)
{
    // if 'arr[]' contains a single element only
    if (n == 1)
        return;
 
    // traverse the array
    for (int i = 0; i < n - 1; i++) {
 
        // if true, perform the required modification
        if ((arr[i] != 0) && (arr[i] == arr[i + 1])) {
 
            // double current index value
            arr[i] = 2 * arr[i];
 
            // put 0 in the next index
            arr[i + 1] = 0;
 
            // increment by 1 so as to move two indexes
            // ahead during loop iteration
            i++;
        }
    }
 
    // push all the zeros at the end of 'arr[]'
    pushZerosToEnd(arr, n);
}
 
// function to print the array elements
void printArray(int arr[], int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
}
 
// Driver program to test above
int main()
{
    int arr[] = { 0, 2, 2, 2, 0, 6, 6, 0, 0, 8 };
    int n = sizeof(arr) / sizeof(arr[0]);
 
    cout << "Original array: ";
    printArray(arr, n);
 
    modifyAndRearrangeArr(arr, n);
 
    cout << "\nModified array: ";
    printArray(arr, n);
 
    return 0;
}

Time complexity: linear
Space complexity: constant
// C++ program to Rearrange positive and negative
// numbers in a array
#include <bits/stdc++.h>
using namespace std;
 
// A utility function to print an array of size n
void printArray(int arr[], int n)
{
    for (int i = 0; i < n; i++)
        cout<<arr[i]<<" ";
}
 
void rotateSubArray(int arr[], int l, int r) {
int temp = arr[r];
for (int j = r; j > l - 1; j--) {
  arr[j] = arr[j - 1];
}
arr[l] = temp;
}
  
void moveNegative(int arr[], int n)
{
 
    int last_negative_index = -1;
     
    for (int i = 0; i < n; i++) {
      if (arr[i] < 0) {
        last_negative_index += 1;
        int 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)
          rotateSubArray(arr, last_negative_index + 1, i);
      }
}
}
  
// Driver Code
int main()
{
    int arr[] = { 5, 5, -3, 4, -8, 0, -7, 3, -9, -3, 9, -2, 1 };
    int n = sizeof(arr) / sizeof(arr[0]);
  
    moveNegative(arr, n);
    printArray(arr, n);
  
    return 0;
}
 
// This code is contributed by Aarti_Rathi

Time complexity: quadratic
Space complexity: constant
// C++ program to Rearrange positive and negative
// numbers in a array
#include <stdio.h>
 
// A utility function to print an array of size n
void printArray(int arr[], int n)
{
    for (int i = 0; i < n; i++)
        printf("%d ", arr[i]);
    printf("\n");
}
 
// Function to Rearrange positive and negative
// numbers in a array
void RearrangePosNeg(int arr[], int n)
{
    int key, j;
    for (int i = 1; i < n; i++) {
        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 && arr[j] > 0) {
            arr[j + 1] = arr[j];
            j = j - 1;
        }
 
        // Put negative element at its right position
        arr[j + 1] = key;
    }
}
 
/* Driver program to test above functions */
int main()
{
    int arr[] = { -12, 11, -13, -5, 6, -7, 5, -3, -6 };
    int n = sizeof(arr) / sizeof(arr[0]);
 
    RearrangePosNeg(arr, n);
    printArray(arr, n);
 
    return 0;
}

Time complexity: quadratic
Space complexity: constant
// C++ program to Rearrange positive and negative
// numbers in a array
#include <iostream>
using namespace std;
 
/* Function to print an array */
void printArray(int A[], int size)
{
    for (int i = 0; i < size; i++)
        cout << A[i] << " ";
    cout << endl;
}
 
// Merges two subarrays of arr[].
// First subarray is arr[l..m]
// Second subarray is arr[m+1..r]
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 = r - m;
 
    /* create temp arrays */
    int L[n1], R[n2];
 
    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1 + j];
 
    /* 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 && L[i] < 0)
        arr[k++] = L[i++];
 
    // copy negative elements of right subarray
    while (j < n2 && R[j] < 0)
        arr[k++] = R[j++];
 
    // copy positive elements of left subarray
    while (i < n1)
        arr[k++] = L[i++];
 
    // copy positive elements of right subarray
    while (j < n2)
        arr[k++] = R[j++];
}
 
// Function to Rearrange positive and negative
// numbers in a array
void RearrangePosNeg(int arr[], int l, int r)
{
    if (l < r) {
        // Same as (l + r)/2, but avoids overflow for
        // large l and h
        int 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 program to test above functions */
int main()
{
    int arr[] = { -12, 11, -13, -5, 6, -7, 5, -3, -6 };
    int arr_size = sizeof(arr) / sizeof(arr[0]);
 
    RearrangePosNeg(arr, 0, arr_size - 1);
 
    printArray(arr, arr_size);
 
    return 0;
}

Time complexity: nlogn
Space complexity: linear
// C++ program to Rearrange positive and negative
// numbers in a array
#include <bits/stdc++.h>
using namespace std;
 
/* Function to print an array */
void printArray(int A[], int size)
{
    for (int i = 0; i < size; i++)
        cout << A[i] << " ";
    cout << endl;
}
 
/* Function to reverse an array. An array can be
reversed in O(n) time and O(1) space. */
void reverse(int arr[], int l, int r)
{
    if (l < r) {
        swap(arr[l], arr[r]);
        reverse(arr, ++l, --r);
    }
}
 
// Merges two subarrays of arr[].
// First subarray is arr[l..m]
// Second subarray is arr[m+1..r]
void merge(int arr[], int l, int m, int r)
{
    int i = l; // Initial index of 1st subarray
    int j = m + 1; // Initial index of IInd
 
    while (i <= m && arr[i] < 0)
        i++;
 
    // arr[i..m] is positive
 
    while (j <= r && arr[j] < 0)
        j++;
 
    // 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
void RearrangePosNeg(int arr[], int l, int r)
{
    if (l < r) {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int 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 */
int main()
{
    int arr[] = { -12, 11, -13, -5, 6, -7, 5, -3, -6 };
    int arr_size = sizeof(arr) / sizeof(arr[0]);
 
    RearrangePosNeg(arr, 0, arr_size - 1);
 
    printArray(arr, arr_size);
 
    return 0;
}

Time complexity: nlogn
Space complexity: logn
#include <bits/stdc++.h>
using namespace std;
void Rearrange(int arr[], int n)
{
    stable_partition(arr,arr+n,[](int x){return x<0;});
}
 
int main()
{
        int n=4;
        int arr[n]={-3, 3, -2, 2};
        Rearrange( arr, n);
       
        for (int i = 0; i < n; i++)
            cout << arr[i] << " ";
        cout << endl; 
}

Time complexity: quadratic
Space complexity: linear
#include <iostream>
using namespace std;
 
void rearrangePosNegWithOrder(int *arr, int size)
{
   int i = 0, j = 0;
   while (j < size) {
       if (arr[j] >= 0) {
           j++;
       }
       else {
           for (int k = j; k > i; k--) {
               int temp = arr[k];
               arr[k] = arr[k - 1];
               arr[k - 1] = temp;
           }
           i++;
           j++;
       }
   }
}
 
int main()
{
 
   int arr[] = { -12, 11, -13, -5, 6, -7, 5, -3, -6 };
   int size = *(&arr + 1) - arr;
   rearrangePosNegWithOrder(arr, size);
   for (int i : arr) {
       cout << i;
       cout << " ";
   }
   return 0;
}

Time complexity: linear
Space complexity: constant
// C++ program to rearrange an array in minimum
// maximum form
#include <bits/stdc++.h>
using namespace std;
 
// Prints max at first position, min at second position
// second max at third position, second min at fourth
// position and so on.
void rearrange(int arr[], int n)
{
    // Auxiliary array to hold modified array
    int temp[n];
 
    // Indexes of smallest and largest elements
    // from remaining array.
    int small = 0, large = n - 1;
 
    // To indicate whether we need to copy remaining
    // largest or remaining smallest at next position
    int flag = true;
 
    // Store result in temp[]
    for (int i = 0; i < n; i++) {
        if (flag)
            temp[i] = arr[large--];
        else
            temp[i] = arr[small++];
 
        flag = !flag;
    }
 
    // Copy temp[] to arr[]
    for (int i = 0; i < n; i++)
        arr[i] = temp[i];
}
 
// Driver code
int main()
{
    int arr[] = { 1, 2, 3, 4, 5, 6 };
    int n = sizeof(arr) / sizeof(arr[0]);
 
    cout << "Original Array\n";
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
 
    rearrange(arr, n);
 
    cout << "\nModified Array\n";
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    return 0;
}

Time complexity: linear
Space complexity: linear
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
void move(vector<int>& arr){
  sort(arr.begin(),arr.end());
}
int main() {
 
    vector<int> arr = { -1, 2, -3, 4, 5, 6, -7, 8, 9 };
      move(arr);
    for (int e : arr)
       cout<<e << " ";
    return 0;
}
 
// This code is contributed by repakaeshwaripriya

Time complexity: nlogn
Space complexity: linear