public TreeNode(int val, TreeNode left = null, TreeNode right = null)
public static TreeNode TrimBST(TreeNode root, int low, int high)
return TrimBST(root.right, low, high);
return TrimBST(root.left, low, high);
root.left = TrimBST(root.left, low, high);
root.right = TrimBST(root.right, low, high);
public static void Main()
Console.WriteLine("UniLecs");
var root = new TreeNode(3);
root.left = new TreeNode(0);
root.right = new TreeNode(4);
root.left.right = new TreeNode(2);
root.left.right.left = new TreeNode(1);
var trimRoot = TrimBST(root, 1, 3);
Console.WriteLine(trimRoot.val);
Console.WriteLine(trimRoot.left.val);
Console.WriteLine(trimRoot.left.left.val);