[Line by line commented] ✅ BFS | Simple HashMap Solution 🔥🔥🔥
java\nclass Solution {\n    public int minimumOperations(TreeNode root) {\n        return solve(root);\n    }\n    \n\t// normal Level Order Traversal\n    int 
```java\nclass Solution {\n    public int minimumOperations(TreeNode root) {\n        return solve(root);\n    }\n    \n\t// normal Level Order Traversal\n    int solve(TreeNode node) {\n\t\tQueue<TreeNode> queue = new LinkedList<>();        // stores nodes at a particular level\n\t\tqueue.add(node);                                   // add the first node to get started\n        \n        int count = 0;\n        \n\t\twhile (!queue.isEmpty()) {\n\t\t\tint size = queue.size();\n\t\t\tint[] arr = new int[size];                     // This stores all the node values of a particular level\n\t\t\tfor (int i = 0; i < size; i++) {\n\t\t\t\tTreeNode currNode = queue.poll();          // take a node out of queue\n\t\t\t\tif (currNode.left != null) {               // if the node has a left child\n\t\t\t\t\tqueue.add(currNode.left);              // add left child to queue for further processing\n\t\t\t\t}\n\t\t\t\tif (currNode.right != null) {              // if the node has a right child\n\t\t\t\t\tqueue.add(currNode.right);             // add right child to queue for further processing\n\t\t\t\t}\n\t\t\t\tarr[i] = currNode.val;                     // store the node [this node is at current level]\n\t\t\t}\n            count += minSwaps(arr);                        // count minimum swaps to make this array sorted\n\t\t}\n\t\treturn count;\n\t}\n    \n\t// calculating minimum swaps required to make array sorted\n    int minSwaps(int[] arr) {\n        Map<Integer, Integer> map = new HashMap<>();            // stores [a number, its index]\n        int[] sortedArr = arr.clone();                          //  make a copy of this array\n        \n        for (int i = 0; i < arr.length; i++) {\n            map.put(arr[i], i);                                 // stores [a number, its index] of original array\n        }\n        \n        Arrays.sort(sortedArr);                                 // sort this copied array\n        \n        int swaps = 0;\n        for (int i = 0; i < arr.length; i++) {\n            if (arr[i] != sortedArr[i]) {                       // whenever a number is not in its correct position, swap it with correct position\n                int index1 = map.get(sortedArr[i]);             // correct index - the number is to be swapped with this index\n                int index2 = map.get(arr[i]);                   // wrong index - the number is currently at this index\n                \n\t\t\t\t// update index in map\n                map.put(arr[i], index1);                      \n                map.put(sortedArr[i], index2);\n\t\t\t\t\n\t\t\t\t// swap the numbers in original array with updated index\n                arr[index1] = arr[i];\n                arr[index2] = sortedArr[i];\n                swaps++;                                        // increase swap count\n            }\n        }\n        \n        return swaps;\n    }\n}\n```
['Java']