✅✅Easiest & Best Solution in C++💯✅
Code\nPlease Upvote if u liked my Solution\uD83D\uDE42\n\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *le
# Code\n**Please Upvote if u liked my Solution**\uD83D\uDE42\n```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n    int minSwaps(vector<int> nums)\n\t{\n\t    int size=nums.size(),count=0;\n\t    vector<pair<int,int>> vec;\n\t    for(int i=0;i<size;i++)\n\t        vec.push_back({nums[i],i});\n\t    sort(vec.begin(),vec.end());\n\t    for(int i=0;i<size;i++){\n\t        while(i!=vec[i].second){\n\t            swap(vec[i],vec[vec[i].second]);\n\t            count++;\n\t        }\n\t    }\n\t    return count;\n\t}\n    int minimumOperations(TreeNode* root) {\n        int count=0;\n        queue<TreeNode*> que;\n        que.push(root);\n        while(que.size()){\n            int size=que.size();\n            vector<int> vec;\n            for(int i=0;i<size;i++){\n                TreeNode* node=que.front();\n                que.pop();\n                vec.push_back(node->val);\n                if(node->left)\n                    que.push(node->left);\n                if(node->right)\n                    que.push(node->right);\n            }\n            count+=minSwaps(vec); \n        }\n        return count;\n    }\n};\n```
['Tree', 'Breadth-First Search', 'Binary Tree', 'C++']