Binary Search Trees

Range Sum Of BST | LeetCode

Range Sum of BST Link Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). The binary search tree is guaranteed to have unique values. Example 1: Input: root = [10,5,15,3,7,null,18], L = 7, R = 15 Output: 32 Example 2: …

Range Sum Of BST | LeetCode Read More »

Convert BST To Greater Tree

Convert BST to Greater Tree Link Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST. Example: Input: The root of a Binary Search Tree like this: …

Convert BST To Greater Tree Read More »

Closest Binary Search Tree Value

Closest Binary Search Tree Value Link Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target. Note: Given target value is a floating point. You are guaranteed to have only one unique value in the BST that is closest to the target. Example: …

Closest Binary Search Tree Value Read More »

Lowest Common Ancestor of a Binary Search Tree

Lowest Common Ancestor of a Binary Search Tree Link Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that …

Lowest Common Ancestor of a Binary Search Tree Read More »

Scroll to Top
[gravityforms id="5" description="false" titla="false" ajax="true"]