## Binary Search Tree Typo

You are given a binary tree root which is almost a binary search tree except two nodes’ values have been swapped. Return the original binary search tree.

You are given a binary tree root which is almost a binary search tree except two nodes’ values have been swapped. Return the original binary search tree.

Given a binary tree root, return the largest sum of a subtree that is also a binary search tree.

Given a binary tree root, return the longest path between any two nodes in the tree.

Given a binary tree root, return the top view of the tree, sorted left-to-right.

Given a binary search tree root, replace every node’s value v by its value plus the sum of all other values in the tree that are greater than v.

Given a binary tree root, consider deleting an edge in the tree so that the tree becomes disjoint with two trees. Then, take the sum of each subtree and mult...

Given a binary tree root, find the most frequent subtree sum. The subtree sum of a node is the sum of all values under a node, including the node itself. You...

Given a binary tree root, and integers a and b, find the value of the lowest node that has a and b as descendants. A node can be a descendant of itself.

Given a binary tree root, return the largest sum of any path between any two nodes.

Given a binary tree root, return the sum of the longest path from the root to a leaf node. If there are two equally long paths, return the larger sum.

Given a singly linked list node, convert it to a binary tree path using these rules:

Given the root to a binary tree root, return the largest sum of any path that goes from the root to a leaf.

Given the root to a binary tree root, return a list of two numbers where the first number is the number of leaves in the tree and the second number is the nu...

Given a binary tree root, return the longest path consisting of even values between any two nodes in the tree.

Given a complete binary tree root, return the number of nodes in the tree.

Given a binary tree root, return the number of unique vertical lines that can be drawn such that every node has a line intersecting it. Each left child is an...

Given a binary tree root, return whether all values in the tree are the same.

A univalue tree is a tree where all nodes under it have the same value.

Given two binary trees, root0 and root1, return whether their structure and values are equal.

Given a binary tree root, return the number of perfect nodes. A perfect node has two properties:

You are given a tree root and a list of strings moves consisting of "RIGHT", "LEFT" and "UP". Starting from root, traverse the tree by performing each move i...

Given a binary tree root, return the sum of all values in the tree.

Given a binary tree root, prune the tree so that subtrees containing all 0s are removed.

Given a list of unique integers preorder and another list of unique integers inorder, representing the pre-order and in-order traversals of a binary tree, re...

You are given a binary tree root where the value of each node represents its color. In the tree there are at most 2 colors. Return whether it’s possible to s...

Given the root to a binary tree root, return whether it is symmetric.

Given two trees root0 and root1, return whether you can transform root0 into root1 by swapping any node’s left and right subtrees any number of times.

Given a binary tree root, return whether for every node in the tree other than the leaves, its value is equal to the sum of its left child’s value and its ri...

You are given two binary search trees a and b and an integer target. Return whether there’s a number in a and a number in b such that their sum equals to tar...

Given a binary tree root, find the sum of the deepest node values.

Given a binary tree root, return the sum of all leaves that are right children.

Given a binary tree root, return the sum of all node values whose grandparents have an even value.

You are given a binary tree root with each node containing single digits from 0 to 9. Each path from the root to the leaf represents a number with its digits...

You are given two binary trees root, and target. Return whether target is a subtree of root — that is, whether there’s a node in root that is identically sam...

Given a binary tree root, return the maximum average value of a subtree. A subtree is defined to be some node in root including all of its descendants. A sub...

You are given an integer k and a binary search tree root, where each node is either a leaf or contains 2 children.

Given a binary tree root, return the depth of the second deepest leaf. Note that if there are multiple deepest leaves, the second deepest leaf is the next hi...

Consider a complete binary tree of n nodes whose values are 1 to n. The root has value of 1, its left child is 2 and its right child is 3. In general, nodes’...

Given a binary search tree root and an integer val, determine whether val is in the tree.

Given a binary tree root where each node contains a digit from 0-9, return whether its in-order traversal is a palindrome.

Given a binary tree root, return the number of nodes that are an only child. A node x is an only child if its parent has exactly one child (x).

You are given a binary tree root containing unique values, and an integer target. Find the node with value target and return the node that’s directly right o...

Given two binary trees node0 and node1, return a merge of the two trees where each value is equal to the sum of the values of the corresponding nodes of the ...

Given a sorted list nums of size n, construct a binary search tree by

Given a sorted linked list node of size n, construct a binary search tree by

Given a binary tree root return a level order traversal of the node values.

Given a binary tree root, convert it to a singly linked list using level order traversal.

Given a binary tree root, return values of the nodes in each level, alternating from going left-to-right and right-to-left.

Given a binary tree root, find the value of the deepest node. If there’s more than one deepest node, then return the leftmost one.

Given a binary tree root, return the leftmost node’s value on each level of the tree.

Given a binary tree root, return whether all leaves are at the same level.

Given two binary trees root0 and root1, return whether the sequence of leaves left-to-right in both trees are the same.

Given a binary search tree root, and k return the kth (0-indexed) smallest value in root. It is guaranteed that the tree has at least k + 1 nodes.

Given a binary tree root, invert it so that its left subtree and right subtree are swapped and the children are recursively inverted.

Given a binary tree root, return an inorder traversal of root as a list.

Given a binary search tree root containing unique values, and an integer t, return the value of the inorder successor of t. That is, return the smallest valu...

Given the root of a binary tree, return whether its height is balanced. That is, for every node in the tree, the absolute difference of the height of its lef...

Given a binary tree root, return the same tree except every node’s value is replaced by its original value plus all of the sums of its left and right subtrees.

Given a binary tree root, return the sum of each of the diagonals in the tree starting from the top to bottom right.

Given a binary tree root, repeatedly delete all leaves that have even values. That is, if after deletions, a node becomes a leaf with an even value, it too s...

Given a binary search tree root, an integer lo, and another an integer hi, remove all nodes that are not between [lo, hi] inclusive.

Given a binary tree root, count and return the number of nodes where its value is greater than or equal to the values of all of its descendants.

Given a binary search tree root, and integers lo and hi, return the count of all nodes in root whose values are between [lo, hi] (inclusive).

Given a binary tree root, remove all nodes with only one child.

Given a binary tree root, return whether it’s a complete binary tree.

Given a binary tree root, convert it to a singly linked list using an inorder traversal.

Given a binary tree root, return whether it’s a binary search tree. A binary tree node is a binary search tree if :

Implement a binary search tree iterator with the following methods: