EASIEST SOLUTION so FARR ||  C++ || BFS || GREEDY SWAP COUNTING
Code

# Code
```cpp []
class Solution {
public:
    int count_swaps(vector<int> a)
    {
        int n = a.size();
        unordered_map<int, int> index;
        vector<int> sa = a;
        sort(sa.begin(), sa.end());
        int swaps = 0;

        for(int i = 0; i < n; i++)
            index[a[i]] = i;

        for(int i = 0; i < n; i++)
        {
            if(index[sa[i]] == i)
                continue;

            swaps++;
            int should_num = sa[i];
            int should_num_idx = index[sa[i]];
            int here_num = a[i];
            int here_num_idx = i;

            index[should_num] = here_num_idx;
            index[here_num] = should_num_idx;

            swap(a[here_num_idx], a[should_num_idx]);
        }   

        return swaps; 
    }

    int minimumOperations(TreeNode* root) {

        int swaps = 0;
        queue<TreeNode*> q;
        q.push(root);

        while(!q.empty())
        {
            int size = q.size();
            vector<int> level;
            for(int i = 0; i < size; i++)
            {
                TreeNode* node = q.front();
                q.pop();

                level.push_back(node->val);

                if(node->left) q.push(node->left);
                if(node->right) q.push(node->right);
            }
            swaps += count_swaps(level);
        }
        return swaps;
    }
};
```
['Tree', 'Breadth-First Search', 'Binary Tree', 'C++']