Leetcode 0572. Subtree of Another Tree

Posted on Sun 15 December 2024 in Leetcode • Tagged with tree-serialization, binary-tree

Question Link : https://leetcode.com/problems/subtree-of-another-tree/

Difficulty: Easy

Premium: False

Question

Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise. A subtree of a binary tree tree …


Continue reading

Leetcode 0297. Serialize and Deserialize Binary Tree

Posted on Thu 12 December 2024 in Leetcode • Tagged with binary-tree

Question Link : https://leetcode.com/problems/serialize-and-deserialize-binary-tree/

Difficulty: Hard

Premium: False

Question

Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed …


Continue reading

Leetcode 0111. Minimum Depth of Binary Tree

Posted on Tue 05 November 2024 in Leetcode • Tagged with bfs, binary-tree

Question Link : https://leetcode.com/problems/minimum-depth-of-binary-tree/

Difficulty: Easy

Premium: False

Question

Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node with no …


Continue reading

Leetcode 0958. Check Completeness of a Binary Tree

Posted on Tue 05 November 2024 in Leetcode • Tagged with binary-tree, bfs

Question Link : https://leetcode.com/problems/check-completeness-of-a-binary-tree/

Difficulty: Medium

Premium: False

Question

Given the root of a binary tree, determine if it is a complete binary tree. In a complete binary tree, every level, except possibly the last, is completely filled, and all nodes in the last level are as …


Continue reading

Leetcode 0129. Sum Root to Leaf Numbers

Posted on Mon 13 March 2023 in Leetcode • Tagged with recursion, binary-tree

Question Link : https://leetcode.com/problems/sum-root-to-leaf-numbers/

Difficulty: Medium

Premium: False

Question

You are given the root of a binary tree containing digits from 0 to 9 only. Each root-to-leaf path in the tree represents a number.

For example, the root-to-leaf path 1 -> 2 -> 3 represents the number 123.

Return …


Continue reading

Leetcode 0124. Binary Tree Maximum Path Sum

Posted on Sat 10 December 2022 in Leetcode • Tagged with recursion, binary-tree

Question Link : https://leetcode.com/problems/binary-tree-maximum-path-sum/

Difficulty: Hard

Premium: False

Question

A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most once. Note that …


Continue reading

Leetcode 1339. Maximum Product of Splitted Binary Tree

Posted on Sat 10 December 2022 in Leetcode • Tagged with binary-tree

Question Link : https://leetcode.com/problems/maximum-product-of-splitted-binary-tree/

Difficulty: Medium

Premium: False

Question

Given the root of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized. Return the maximum product of the sums of …


Continue reading

Leetcode 0222. Count Complete Tree Nodes

Posted on Mon 14 November 2022 in Leetcode • Tagged with binary-tree

Question Link : https://leetcode.com/problems/count-complete-tree-nodes/

Difficulty: Medium

Question

Given the root of a complete binary tree, return the number of the nodes in the tree. According to Wikipedia, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last …


Continue reading

Leetcode 0112. Path Sum

Posted on Tue 04 October 2022 in Leetcode • Tagged with binary-tree, recursion

Question Link : https://leetcode.com/problems/path-sum/

Difficulty: Easy

Question

Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum. A leaf is a node with no children …


Continue reading

Leetcode 0606. Construct String from Binary Tree

Posted on Mon 28 February 2022 in Leetcode • Tagged with recursion, binary-tree

Question Link : https://leetcode.com/problems/construct-string-from-binary-tree/

Difficulty: Easy

Question

Given the root of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it. Omit all the empty parenthesis pairs that do not affect the one-to-one mapping …


Continue reading