leetcode.cn 2023-09-06
🟡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.cn 2023-09-18
🟡337.house-robber-iii
🏷️ Tags
#tree #depth_first_search #dynamic_programming #binary_tree
🟡337.house-robber-iii
🏷️ Tags
#tree #depth_first_search #dynamic_programming #binary_tree
Telegraph
house-robber-iii
小偷又发现了一个新的可行窃的地区。这个地区只有一个入口,我们称之为 root 。 除了 root 之外,每栋房子有且只有一个“父“房子与之相连。一番侦察之后,聪明的小偷意识到“这个地方的所有房屋的排列类似于一棵二叉树”。 如果 两个直接相连的房子在同一天晚上被打劫 ,房屋将自动报警。 给定二叉树的 root 。返回 在不触动警报的情况下 ,小偷能够盗取的最高金额 。 示例 1: 输入: root = [3,2,3,null,3,null,1] 输出: 7 解释: 小偷一晚能够盗取的最高金额 3 + 3…
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:…