All Posts

Leetcode 606: Construct String from Binary Tree

Given the root node of a binary tree, generate a string representation of the tree following specific formatting rules based on a preorder traversal.

Leetcode 617: Merge Two Binary Trees

Given two binary trees, merge them into a new binary tree where overlapping nodes are summed, and non-overlapping nodes are retained as they are.

Leetcode 623: Add One Row to Tree

You are given the root of a binary tree, and two integers val and depth. You need to add a row of nodes with value val at the given depth depth. The root node is considered to be at depth 1.

Leetcode 652: Find Duplicate Subtrees

Given the root of a binary tree, return all duplicate subtrees. For each duplicate subtree, return the root node of any one of them. Two trees are considered duplicates if they have the same structure and node values.

Leetcode 654: Maximum Binary Tree

Given an integer array nums with no duplicates, construct a maximum binary tree by recursively selecting the largest number as the root, and building the left and right subtrees from the elements before and after the largest number.

Leetcode 655: Print Binary Tree

Given the root of a binary tree, construct a matrix representation of the tree using specific formatting rules to place each node in the appropriate position in the matrix.