leetcode.com 2023-10-17
🟡1361.validate-binary-tree-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #union_find #graph #binary_tree
🟡1361.validate-binary-tree-nodes
🏷️ Tags
#tree #depth_first_search #breadth_first_search #union_find #graph #binary_tree
Telegraph
validate-binary-tree-nodes
You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one valid binary tree. If node i has no left child then leftChild[i] will equal…
leetcode.com 2023-10-24
🟡515.find-largest-value-in-each-tree-row
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡515.find-largest-value-in-each-tree-row
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
find-largest-value-in-each-tree-row
Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed). Example 1: Input: root = [1,3,2,5,3,null,9] Output: [1,3,9] Example 2: Input: root = [1,2,3] Output: [1,3] Constraints:
leetcode.com 2023-11-01
🟢501.find-mode-in-binary-search-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
🟢501.find-mode-in-binary-search-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
Telegraph
find-mode-in-binary-search-tree
Given the root of a binary search tree (BST) with duplicates, return all the mode(s) (i.e., the most frequently occurred element) in it. If the tree has more than one mode, return them in any order. Assume a BST is defined as follows:
👍1
leetcode.com 2023-11-02
🟡2265.count-nodes-equal-to-average-of-subtree
🏷️ Tags
#tree #depth_first_search #binary_tree
🟡2265.count-nodes-equal-to-average-of-subtree
🏷️ Tags
#tree #depth_first_search #binary_tree
Telegraph
count-nodes-equal-to-average-of-subtree
Given the root of a binary tree, return the number of nodes where the value of the node is equal to the average of the values in its subtree. Note:
leetcode.cn 2023-11-03
🟡117.populating-next-right-pointers-in-each-node-ii
🏷️ Tags
#tree #depth_first_search #breadth_first_search #linked_list #binary_tree
🟡117.populating-next-right-pointers-in-each-node-ii
🏷️ Tags
#tree #depth_first_search #breadth_first_search #linked_list #binary_tree
Telegraph
populating-next-right-pointers-in-each-node-ii
给定一个二叉树: struct Node { int val; Node *left; Node *right; Node *next; } 填充它的每个 next 指针,让这个指针指向其下一个右侧节点。如果找不到下一个右侧节点,则将 next 指针设置为 NULL 。 初始状态下,所有 next 指针都被设置为 NULL 。 示例 1: 输入:root = [1,2,3,4,5,null,7] 输出:[1,#,2,3,#,4,5,7,#] 解释:给定二叉树如图 A 所示,你的函数应该填充它的每个 next…
leetcode.cn 2023-11-25
🟡1457.pseudo-palindromic-paths-in-a-binary-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #breadth_first_search #binary_tree
🟡1457.pseudo-palindromic-paths-in-a-binary-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
pseudo-palindromic-paths-in-a-binary-tree
给你一棵二叉树,每个节点的值为 1 到 9 。我们称二叉树中的一条路径是 「伪回文」的,当它满足:路径经过的所有节点值的排列中,存在一个回文序列。 请你返回从根到叶子节点的所有路径中 伪回文 路径的数目。 示例 1: 输入:root = [2,3,1,3,1,null,1] 输出:2 解释:上图为给定的二叉树。总共有 3 条从根到叶子的路径:红色路径 [2,3,3] ,绿色路径 [2,1,1] 和路径 [2,3,1] 。 在这些路径中,只有红色和绿色的路径是伪回文路径,因为红色路径 [2,3,3] 存在回文排列…
leetcode.cn 2023-12-04
🟡1038.binary-search-tree-to-greater-sum-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
🟡1038.binary-search-tree-to-greater-sum-tree
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
Telegraph
binary-search-tree-to-greater-sum-tree
给定一个二叉搜索树 root (BST),请将它的每个节点的值替换成树中大于或者等于该节点值的所有节点值之和。 提醒一下, 二叉搜索树 满足下列约束条件:
leetcode.com 2023-12-08
🟢606.construct-string-from-binary-tree
🏷️ Tags
#tree #depth_first_search #string #binary_tree
🟢606.construct-string-from-binary-tree
🏷️ Tags
#tree #depth_first_search #string #binary_tree
Telegraph
construct-string-from-binary-tree
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 relationship between…
leetcode.com 2023-12-09
🟢94.binary-tree-inorder-traversal
🏷️ Tags
#stack #tree #depth_first_search #binary_tree
🟢94.binary-tree-inorder-traversal
🏷️ Tags
#stack #tree #depth_first_search #binary_tree
Telegraph
binary-tree-inorder-traversal
Given the root of a binary tree, return the inorder traversal of its nodes' values. Example 1: Input: root = [1,null,2,3] Output: [1,3,2] Example 2: Input: root = [] Output: [] Example 3: Input: root = [1] Output: [1] Constraints:
leetcode.cn 2023-12-15
🟡2415.reverse-odd-levels-of-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡2415.reverse-odd-levels-of-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
reverse-odd-levels-of-binary-tree
给你一棵 完美 二叉树的根节点 root ,请你反转这棵树中每个 奇数 层的节点值。
leetcode.com 2024-01-08
🟢938.range-sum-of-bst
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
🟢938.range-sum-of-bst
🏷️ Tags
#tree #depth_first_search #binary_search_tree #binary_tree
Telegraph
range-sum-of-bst
Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high]. Example 1: Input: root = [10,5,15,3,7,null,18], low = 7, high = 15 Output: 32 Explanation:…
leetcode.com 2024-01-10
🟡2385.amount-of-time-for-binary-tree-to-be-infected
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
🟡2385.amount-of-time-for-binary-tree-to-be-infected
🏷️ Tags
#tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
amount-of-time-for-binary-tree-to-be-infected
You are given the root of a binary tree with unique values, and an integer start. At minute 0, an infection starts from the node with value start. Each minute, a node becomes infected if:
leetcode.com 2024-01-11
🟡1026.maximum-difference-between-node-and-ancestor
🏷️ Tags
#tree #depth_first_search #binary_tree
🟡1026.maximum-difference-between-node-and-ancestor
🏷️ Tags
#tree #depth_first_search #binary_tree
Telegraph
maximum-difference-between-node-and-ancestor
Given the root of a binary tree, find the maximum value v for which there exist different nodes a and b where v = |a.val - b.val| and a is an ancestor of b. A node a is an ancestor of b if either: any child of a is equal to b or any child of a is an ancestor…
leetcode.com 2024-01-24
🟡1457.pseudo-palindromic-paths-in-a-binary-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #breadth_first_search #binary_tree
🟡1457.pseudo-palindromic-paths-in-a-binary-tree
🏷️ Tags
#bit_manipulation #tree #depth_first_search #breadth_first_search #binary_tree
Telegraph
pseudo-palindromic-paths-in-a-binary-tree
Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be pseudo-palindromic if at least one permutation of the node values in the path is a palindrome. Return the number of pseudo-palindromic paths going from the…
leetcode.com 2025-02-21
🟡1261.find-elements-in-a-contaminated-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #hash_table #binary_tree
🟡1261.find-elements-in-a-contaminated-binary-tree
🏷️ Tags
#tree #depth_first_search #breadth_first_search #design #hash_table #binary_tree
Telegraph
find-elements-in-a-contaminated-binary-tree
Given a binary tree with the following rules:
leetcode.com 2025-02-22
🔴1028.recover-a-tree-from-preorder-traversal
🏷️ Tags
#tree #depth_first_search #string #binary_tree
🔴1028.recover-a-tree-from-preorder-traversal
🏷️ Tags
#tree #depth_first_search #string #binary_tree
Telegraph
recover-a-tree-from-preorder-traversal
We run a preorder depth-first search (DFS) on the root of a binary tree. At each node in this traversal, we output D dashes (where D is the depth of this node), then we output the value of this node. If the depth of a node is D, the depth of its immediate…
leetcode.com 2025-02-23
🟡889.construct-binary-tree-from-preorder-and-postorder-traversal
🏷️ Tags
#tree #array #hash_table #divide_and_conquer #binary_tree
🟡889.construct-binary-tree-from-preorder-and-postorder-traversal
🏷️ Tags
#tree #array #hash_table #divide_and_conquer #binary_tree
Telegraph
construct-binary-tree-from-preorder-and-postorder-traversal
Given two integer arrays, preorder and postorder where preorder is the preorder traversal of a binary tree of distinct values and postorder is the postorder traversal of the same tree, reconstruct and return the binary tree. If there exist multiple answers…
leetcode.cn 2025-04-04
🟡1123.lowest-common-ancestor-of-deepest-leaves
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
🟡1123.lowest-common-ancestor-of-deepest-leaves
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
Telegraph
lowest-common-ancestor-of-deepest-leaves
给你一个有根节点 root 的二叉树,返回它 最深的叶节点的最近公共祖先 。 回想一下:
leetcode.com 2025-04-04
🟡1123.lowest-common-ancestor-of-deepest-leaves
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
🟡1123.lowest-common-ancestor-of-deepest-leaves
🏷️ Tags
#tree #depth_first_search #breadth_first_search #hash_table #binary_tree
Telegraph
lowest-common-ancestor-of-deepest-leaves
Given the root of a binary tree, return the lowest common ancestor of its deepest leaves. Recall that: