#include "partition.h"
#include <bits/stdc++.h>
using namespace std;

std::vector<int> solve(std::vector<int> A) {
    int n=A.size();
    vector<int> a=A;
    vector<int> ans(n);
    map<int,int> mp;
    int j=0;
    int o=n-1;
    for(int i=0;i<n;i++){
        if(mp[a[i]]%2==1){
            ans[o]=i;
            o--;
        }
        else{
            ans[j]=i;
            j++;
        }
        mp[a[i]]++;
    }
    return ans;
}
