All Posts

Leetcode 449: Serialize and Deserialize BST

Design an algorithm to serialize and deserialize a binary search tree (BST). Serialization is converting the tree to a string format, while deserialization reconstructs the tree from this string. The goal is to ensure that the BST can be serialized to a compact string and can be accurately deserialized back into the original tree structure.

Leetcode 501: Find Mode in Binary Search Tree

Given the root of a binary search tree (BST) with possible duplicates, return the mode(s) (i.e., the most frequently occurring element) in the tree. If there are multiple modes, return them in any order.

Leetcode 530: Minimum Absolute Difference in BST

Given the root of a Binary Search Tree (BST), return the minimum absolute difference between the values of any two different nodes in the tree.

Leetcode 538: Convert BST to Greater Tree

Given the root of a Binary Search Tree (BST), convert it into a Greater Tree where every node’s value is replaced by the sum of all greater node values in the BST plus its original value.

Leetcode 669: Trim a Binary Search Tree

You are given the root of a binary search tree (BST) and two integer values low and high. Trim the tree such that all its elements lie within the inclusive range [low, high]. The tree’s relative structure should remain unchanged, and the root may change depending on the given bounds.

Leetcode 703: Kth Largest Element in a Stream

You are tasked with implementing a class that helps track the kth highest score in a dynamic list of test scores. Each time a new score is submitted, you need to return the kth highest score in the list.