easy java solution || easy approach|| simple BFS || level order traversal
easy java solution\n\nclass Solution {\n    public int minimumOperations(TreeNode root) {\n        if(root==null) return 0;\n     Queue q=new LinkedList<>();\n 
easy java solution\n\nclass Solution {\n    public int minimumOperations(TreeNode root) {\n        if(root==null) return 0;\n     Queue<TreeNode> q=new LinkedList<>();\n        q.add(root);int totalOp=0;\n        while(!q.isEmpty()){\n            List<Integer> currLevel=new ArrayList<>();\n            int size=q.size();\n            for(int i=0;i<size;i++){\n                TreeNode curr=q.poll();\n                currLevel.add(curr.val);\n                if(curr.left!=null) q.add(curr.left);\n                if(curr.right!=null) q.add(curr.right);\n            }totalOp+=calMinSwap(currLevel);\n        }return totalOp;\n    }\n    public int calMinSwap(List<Integer> level){\n        int n=level.size();\n        int arr[]=level.stream().mapToInt(i->i).toArray();\n        int sortedArr[]=arr.clone();Arrays.sort(sortedArr);\n        Map<Integer,Integer> idxMap=new HashMap<>();\n        for(int i=0;i<n;i++){\n            idxMap.put(sortedArr[i],i);\n        }\n        boolean visited[]=new boolean[n];\n        int swaps=0;\n        for(int i=0;i<n;i++){\n            if(visited[i]||idxMap.get(arr[i])==i){\n                continue;\n            }\n            int cycleSize=0;\n            int j=i;\n            while(!visited[j]){\n                visited[j]=true;\n                j=idxMap.get(arr[j]);\n                cycleSize++;\n            }\n            if(cycleSize>1){\n                swaps+=(cycleSize-1);\n            }\n        }return swaps;\n    }\n}
['Breadth-First Search', 'Java']