Easy Java Solution || BFS
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode() {}\n *     TreeNode(int val) { this.val = val; }\n *     TreeNode(int val, TreeNode left, TreeNode right) {\n *         this.val = val;\n *         this.left = left;\n *         this.right = right;\n *     }\n * }\n */\nclass Solution {\n public int indexOf(int[] arr, int ele){\n    for (int i=0;i<arr.length;i++){\n            if (arr[i]==ele) {\n                return i;\n            }\n        }\n        return -1;\n    }\n    public void swap(int[] arr, int i, int j){\n        int temp=arr[i];\n        arr[i]=arr[j];\n        arr[j]=temp;\n    }\n    public int minSwaps(int[] arr, int N){\n        int ans = 0;\n        int[] temp=Arrays.copyOfRange(arr, 0, N);\n        Arrays.sort(temp);\n        for (int i=0;i<N;i++){\n            if (arr[i]!=temp[i]){\n                ans++;\n                swap(arr,i,indexOf(arr, temp[i]));\n            }\n        }\n        return ans;\n    }\n    public int minimumOperations(TreeNode root) {\n        Queue<TreeNode>q=new LinkedList<>();\n        q.add(root);\n        int count=0;\n        while(!q.isEmpty()){\n            TreeNode curr=q.peek();\n            int size=q.size();\n            for(int i=0;i<size;i++){\n                curr=q.remove();\n                if(curr.left!=null){\n                    q.add(curr.left);\n                }\n                if(curr.right!=null){\n                    q.add(curr.right);\n                }\n            }\n           int[] arr=new int[q.size()];\n            int k=0;\n            for(TreeNode num: q){\n                arr[k++] = num.val;\n            }\n            count+=minSwaps(arr, k);\n        }\n        return count;\n    }\n}\n```
['Java']