原文链接: https://leetcode-cn.com/problems/binary-search-tree-to-greater-sum-tree 英文原文Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all ke…
标签详情
树 分类
原文链接: https://leetcode-cn.com/problems/maximum-level-sum-of-a-binary-tree 英文原文Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level x such that the sum of all the values of n…
原文链接: https://leetcode-cn.com/problems/insufficient-nodes-in-root-to-leaf-paths 英文原文Given the root of a binary tree and an integer limit, delete all insufficient nodes in the tree simultaneously, and return the root of the resulting binary tree. A no…
原文链接: https://leetcode-cn.com/problems/path-in-zigzag-labelled-binary-tree 英文原文In an infinite binary tree where every node has two children, the nodes are labelled in row order. In the odd numbered rows (ie., the first, third, fifth,...), the labelli…
原文链接: https://leetcode-cn.com/problems/delete-nodes-and-return-forest 英文原文Given the root of a binary tree, each node in the tree has a distinct value. After deleting all nodes with a value in to_delete, we are left with a forest (a disjoint union of …
原文链接: https://leetcode-cn.com/problems/lowest-common-ancestor-of-deepest-leaves 英文原文Given the root of a binary tree, return the lowest common ancestor of its deepest leaves. Recall that: The node of a binary tree is a leaf if and only if it has no ch…
原文链接: https://leetcode-cn.com/problems/sum-of-nodes-with-even-valued-grandparent 英文原文Given the root of a binary tree, return the sum of values of nodes with an even-valued grandparent. If there are no nodes with an even-valued grandparent, return 0. …
原文链接: https://leetcode-cn.com/problems/binary-tree-coloring-game 英文原文Two players play a turn based game on a binary tree. We are given the root of this binary tree, and the number of nodes n in the tree. n is odd, and each node has a distinct value f…
原文链接: https://leetcode-cn.com/problems/deepest-leaves-sum 英文原文Given the root of a binary tree, return the sum of values of its deepest leaves. Example 1: Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8] Output: 15 Example 2: Input: root = [6,…
原文链接: https://leetcode-cn.com/problems/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 …
原文链接: https://leetcode-cn.com/problems/balance-a-binary-search-tree 英文原文Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them. A binary search tree…
原文链接: https://leetcode-cn.com/problems/kth-ancestor-of-a-tree-node 英文原文You are given a tree with n nodes numbered from 0 to n - 1 in the form of a parent array parent where parent[i] is the parent of ith node. The root of the tree is node 0. Find the…
原文链接: https://leetcode-cn.com/problems/count-ways-to-build-rooms-in-an-ant-colony 英文原文You are an ant tasked with adding n new rooms numbered 0 to n-1 to your colony. You are given the expansion plan as a 0-indexed integer array of length n, prevRoom,…
原文链接: https://leetcode-cn.com/problems/find-elements-in-a-contaminated-binary-tree 英文原文Given a binary tree with the following rules: root.val == 0 If treeNode.val == x and treeNode.left != null, then treeNode.left.val == 2 * x + 1 If treeNode.val == …
原文链接: https://leetcode-cn.com/problems/all-elements-in-two-binary-search-trees 英文原文Given two binary search trees root1 and root2. Return a list containing all the integers from both trees sorted in ascending order. Example 1: Input: root1 = [2,1,4], …
原文链接: https://leetcode-cn.com/problems/maximum-product-of-splitted-binary-tree 英文原文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 th…
原文链接: https://leetcode-cn.com/problems/longest-zigzag-path-in-a-binary-tree 英文原文You are given the root of a binary tree. A ZigZag path for a binary tree is defined as follow: Choose any node in the binary tree and a direction (right or left). If the …
原文链接: https://leetcode-cn.com/problems/maximum-sum-bst-in-binary-tree 英文原文Given a binary tree root, return the maximum sum of all keys of any sub-tree which is also a Binary Search Tree (BST). Assume a BST is defined as follows: The left subtree of a…
原文链接: https://leetcode-cn.com/problems/linked-list-in-binary-tree 英文原文Given a binary tree root and a linked list with head as the first node. Return True if all the elements in the linked list starting from the head correspond to some downward path c…
原文链接: https://leetcode-cn.com/problems/time-needed-to-inform-all-employees 英文原文A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company is the one with headID. Each employee has one direct manager given in…
原文链接: https://leetcode-cn.com/problems/frog-position-after-t-seconds 英文原文Given an undirected tree consisting of n vertices numbered from 1 to n. A frog starts jumping from vertex 1. In one second, the frog jumps from its current vertex to another unv…
原文链接: https://leetcode-cn.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree 英文原文Given two binary trees original and cloned and given a reference to a node target in the original tree. The cloned tree is a copy of the ori…
原文链接: https://leetcode-cn.com/problems/count-good-nodes-in-binary-tree 英文原文Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X. Return the number of good nodes in t…
原文链接: https://leetcode-cn.com/problems/minimum-time-to-collect-all-apples-in-a-tree 英文原文Given an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices. You spend 1 second to walk over one edge of the…
原文链接: https://leetcode-cn.com/problems/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 valu…
原文链接: https://leetcode-cn.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label 英文原文Given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of th…
原文链接: https://leetcode-cn.com/problems/number-of-good-leaf-nodes-pairs 英文原文Given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them…
原文链接: https://leetcode-cn.com/problems/number-of-ways-to-reorder-array-to-get-same-bst 英文原文Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nu…
原文链接: https://leetcode-cn.com/problems/throne-inheritance 英文原文A kingdom consists of a king, his children, his grandchildren, and so on. Every once in a while, someone in the family dies or a child is born. The kingdom has a well-defined order of inhe…
原文链接: https://leetcode-cn.com/problems/even-odd-tree 英文原文A binary tree is named Even-Odd if it meets the following conditions: The root of the binary tree is at level index 0, its children are at level index 1, their children are at level index 2, et…