All Posts

Leetcode 988: Smallest String Starting From Leaf

You are given the root of a binary tree, where each node contains a value between 0 and 25, corresponding to letters from ‘a’ to ‘z’. Your task is to find the lexicographically smallest string that can be formed by traversing from a leaf node to the root node, using the values in each node as letters.

Leetcode 998: Maximum Binary Tree II

You are given the root of a maximum binary tree and an integer val. The task is to insert val into the tree by constructing a new maximum binary tree with a list that contains val appended to the original list used to construct the tree.

Leetcode 1008: Construct Binary Search Tree from Preorder Traversal

You are given an array representing the preorder traversal of a binary search tree (BST). Your task is to construct the BST from this preorder traversal and return the root of the tree.

Leetcode 1026: Maximum Difference Between Node and Ancestor

You are given the root of a binary tree. Your task is to find the maximum absolute difference between the values of two nodes, where one node is an ancestor of the other. Specifically, you need to find the largest value of |a.val - b.val|, where node a is an ancestor of node b.

Leetcode 1038: Binary Search Tree to Greater Sum Tree

Given the root of a Binary Search Tree (BST), convert it into a Greater Tree where each node’s value is updated to the sum of its original value and all the values greater than it in the BST. The transformation should preserve the BST structure.

Leetcode 1080: Insufficient Nodes in Root to Leaf Paths

You are given the root of a binary tree and an integer limit. Your task is to delete all nodes in the tree that are considered insufficient. A node is insufficient if every root-to-leaf path passing through that node has a sum strictly less than the given limit. A leaf is defined as a node with no children. Return the root of the resulting binary tree after the deletions.