All Posts

Leetcode 662: Maximum Width of Binary Tree

You are given the root of a binary tree. Determine the maximum width of the tree, which is defined as the maximum width among all levels. The width of a level is the distance between the leftmost and rightmost non-null nodes, including null nodes in between that would be present in a complete binary tree.

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 687: Longest Univalue Path

You are given the root of a binary tree. The task is to find the length of the longest path in the tree where all the nodes in the path have the same value. The path can be anywhere in the tree, not necessarily passing through the root. The path length is determined by the number of edges between the nodes.

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.

Leetcode 814: Binary Tree Pruning

You are given the root of a binary tree. Your task is to remove all subtrees in the tree that do not contain at least one node with the value 1. A subtree is defined as the node and all its descendants. Return the modified tree.

Leetcode 863: All Nodes Distance K in Binary Tree

Given a binary tree, a target node within the tree, and a non-negative integer k, determine all the nodes that are exactly k edges away from the target node. Return these node values as a list in any order.