/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ publicclassSolution{ publicintgetMinimumDifference(TreeNode root){ List<Integer> list = new ArrayList<>(); helper(root, list); int result = Integer.MAX_VALUE; for (int i = 1; i < list.size(); i++) { result = Math.min(result, list.get(i) - list.get(i - 1)); } return result; }