原文链接: https://leetcode-cn.com/problems/kth-largest-element-in-a-stream 英文原文Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Implement KthLargest cla…
标签详情
二叉树 分类
原文链接: https://leetcode-cn.com/problems/minimum-distance-between-bst-nodes 英文原文Given the root of a Binary Search Tree (BST), return the minimum difference between the values of any two different nodes in the tree. Example 1: Input: root = [4,2,6,1,3] …
原文链接: https://leetcode-cn.com/problems/binary-tree-pruning 英文原文Given the root of a binary tree, return the same tree where every subtree (of the given tree) not containing a 1 has been removed. A subtree of a node node is node plus every node that is…
原文链接: https://leetcode-cn.com/problems/all-nodes-distance-k-in-binary-tree 英文原文Given the root of a binary tree, the value of a target node target, and an integer k, return an array of the values of all nodes that have a distance k from the target nod…
原文链接: https://leetcode-cn.com/problems/smallest-subtree-with-all-the-deepest-nodes 英文原文Given the root of a binary tree, the depth of each node is the shortest distance to the root. Return the smallest subtree such that it contains all the deepest nod…
原文链接: https://leetcode-cn.com/problems/leaf-similar-trees 英文原文Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence. For example, in the given tree above, the leaf value sequence is …
原文链接: https://leetcode-cn.com/problems/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 …
原文链接: https://leetcode-cn.com/problems/all-possible-full-binary-trees 英文原文Given an integer n, return a list of all possible full binary trees with n nodes. Each node of each tree in the answer must have Node.val == 0. Each element of the answer is th…
原文链接: https://leetcode-cn.com/problems/increasing-order-search-tree 英文原文Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and onl…
原文链接: https://leetcode-cn.com/problems/complete-binary-tree-inserter 英文原文A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible. Design an algorithm to i…
原文链接: https://leetcode-cn.com/problems/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…
原文链接: https://leetcode-cn.com/problems/check-completeness-of-a-binary-tree 英文原文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…
原文链接: https://leetcode-cn.com/problems/univalued-binary-tree 英文原文A binary tree is uni-valued if every node in the tree has the same value. Given the root of a binary tree, return true if the given tree is uni-valued, or false otherwise. Example 1: In…
原文链接: https://leetcode-cn.com/problems/binary-tree-cameras 英文原文You are given the root of a binary tree. We install cameras on the tree nodes where each camera at a node can monitor its parent, itself, and its immediate children. Return the minimum nu…
原文链接: https://leetcode-cn.com/problems/flip-binary-tree-to-match-preorder-traversal 英文原文You are given the root of a binary tree with n nodes, where each node is uniquely assigned a value from 1 to n. You are also given a sequence of n values voyage, …
原文链接: https://leetcode-cn.com/problems/distribute-coins-in-binary-tree 英文原文You are given the root of a binary tree with n nodes where each node in the tree has node.val coins. There are n coins in total throughout the whole tree. In one move, we may …
原文链接: https://leetcode-cn.com/problems/vertical-order-traversal-of-a-binary-tree 英文原文Given the root of a binary tree, calculate the vertical order traversal of the binary tree. For each node at position (row, col), its left and right children will be…
原文链接: https://leetcode-cn.com/problems/smallest-string-starting-from-leaf 英文原文You are given the root of a binary tree where each node has a value in the range [0, 25] representing the letters 'a' to 'z'. Return the lexicographically smallest string t…
原文链接: https://leetcode-cn.com/problems/cousins-in-binary-tree 英文原文Given the root of a binary tree with unique values and the values of two different nodes of the tree x and y, return true if the nodes corresponding to the values x and y in the tree a…
原文链接: https://leetcode-cn.com/problems/maximum-binary-tree-ii 英文原文A maximum tree is a tree where every node has a value greater than any other value in its subtree. You are given the root of a maximum binary tree and an integer val. Just as in the pr…
原文链接: https://leetcode-cn.com/problems/construct-binary-search-tree-from-preorder-traversal 英文原文Given an array of integers preorder, which represents the preorder traversal of a BST (i.e., binary search tree), construct the tree and return its root. …
原文链接: https://leetcode-cn.com/problems/sum-of-root-to-leaf-binary-numbers 英文原文You are given the root of a binary tree where each node has a value 0 or 1. Each root-to-leaf path represents a binary number starting with the most significant bit. For ex…
原文链接: https://leetcode-cn.com/problems/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 nod…
原文链接: https://leetcode-cn.com/problems/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…
原文链接: 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…