Largest Number Smaller in BST
PreviousGreatest difference Left and Right subtree count NodeNextClosest Number in Binary Search Tree II
Last updated
Last updated
public int largestSmaller(TreeNode root, int target){
int result = Integer.MIN_VALUE;
while (root != null){
if (root.key >= target){
root = root.left;
} else {
result = root.key;
root = root.right;
}
}
return root;
}