Easy Java Solution
```\nclass Solution {\n    public int minimumOperations(TreeNode root) {\n        int count = 0;\n        Queue q = new LinkedList<>();\n        q.offer(root);\
```\nclass Solution {\n    public int minimumOperations(TreeNode root) {\n        int count = 0;\n        Queue<TreeNode> q = new LinkedList<>();\n        q.offer(root);\n        while(!q.isEmpty()) {\n            int size = q.size();\n            List<Integer> list = new ArrayList<>();\n            while(size-- > 0) {\n                TreeNode node = q.poll();\n                if(node.left != null) {\n                    q.offer(node.left);\n                    list.add(node.left.val);\n                }\n                if(node.right != null) {\n                    q.offer(node.right);\n                    list.add(node.right.val);\n                }\n            }\n            count += helper(list);\n        }\n        \n        return count;\n    }\n    \n    int helper(List<Integer> list) {\n        int swaps = 0;\n        int[] sorted = new int[list.size()];\n        for(int i=0; i<sorted.length; i++) sorted[i] = list.get(i);\n        Arrays.sort(sorted);\n        Map<Integer, Integer> ind = new HashMap<>();\n        for(int i=0; i<list.size(); i++) ind.put(list.get(i), i);\n        \n        for(int i=0; i<list.size(); i++) {\n            if(list.get(i) != sorted[i]) {\n                swaps++;\n                ind.put(list.get(i), ind.get(sorted[i]));\n                list.set(ind.get(sorted[i]), list.get(i));\n            }\n        }\n        return swaps;\n    }\n}
['Java']