BFS +Binary Search(Lower-Bound) || C++
\n int minimumOperations(TreeNode* root) {\n        int ans=0;\n        queue<TreeNode*>q;\n        q.push(root);\n        while(!q.empty()){\n            int s
```\n int minimumOperations(TreeNode* root) {\n        int ans=0;\n        queue<TreeNode*>q;\n        q.push(root);\n        while(!q.empty()){\n            int size=q.size();\n            vector<int>temp,sorted;\n            while(size--){\n                 auto top=q.front();\n                 q.pop();\n                temp.push_back(top->val);\n                sorted.push_back(top->val);\n                if(top->left){\n                    q.push(top->left);\n                }\n                if(top->right){\n                    q.push(top->right);\n                }\n            }\n            sort(sorted.begin(),sorted.end());\n            int n=temp.size();\n            int i=0;\n            while(i<n){\n                int lind=lower_bound(sorted.begin(),sorted.end(),temp[i])-sorted.begin();\n                if(temp[lind]==temp[i]){\n                    i++;\n                }\n                else{\n                    swap(temp[lind],temp[i]);\n                    ans++;\n                }\n            }\n        }\n        return ans;\n    }\n```\n\n**Please upvote if you liked it.\nThank You :)**
['Breadth-First Search', 'Binary Tree']