#include "partition.h"
#include <bits/stdc++.h>

std::vector<int> solve(std::vector<int> A) {

    const int N = A.size();

    std::unordered_set<int> seen;
    std::vector<int> later;
    std::vector<int> ans;

    for (int i = 0; i < N; i++) {
        if (seen.find(A[i]) == seen.end()) {
            ans.push_back(i);
            seen.insert(A[i]);
        } else {
            later.push_back(i);
        }
    }

    for (const int &i : later) {
        ans.push_back(i);
    }

    return ans;
}
