c++ optimize big int array

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void optimizeBigIntArray(vector<int>& bigIntArray) {
    // Step 1: Sort the array
    sort(bigIntArray.begin(), bigIntArray.end());

    // Step 2: Remove duplicates
    auto it = unique(bigIntArray.begin(), bigIntArray.end());
    bigIntArray.resize(distance(bigIntArray.begin(), it));

    // Step 3: Shrink the capacity to fit the actual size
    vector<int>(bigIntArray.begin(), bigIntArray.end()).swap(bigIntArray);
}

int main() {
    // Example usage
    vector<int> bigIntArray = {5, 3, 2, 8, 3, 5, 1, 2};
    optimizeBigIntArray(bigIntArray);

    // Access the optimized array
    for (int num : bigIntArray) {
        cout << num << " ";
    }

    return 0;
}