776. Split BST
Description
Given the root
of a binary search tree (BST) and an integer target
, split the tree into two subtrees where the first subtree has nodes that are all smaller or equal to the target value, while the second subtree has all nodes that are greater than the target value. It is not necessarily the case that the tree contains a node with the value target
.
671. Second Minimum Node In a Binary Tree
671. Second Minimum Node In a Binary Tree
Description
Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two
or zero
sub-node. If the node has two sub-nodes, then this node’s value is the smaller value among its two sub-nodes. More formally, the propertyroot.val = min(root.left.val, root.right.val)
always holds.
669. Trim a Binary Search Tree
669. Trim a Binary Search Tree
Description
Given the root
of a binary search tree and the lowest and highest boundaries as low
and high
, trim the tree so that all its elements lies in [low, high]
. Trimming the tree should not change the relative structure of the elements that will remain in the tree (i.e., any node’s descendant should remain a descendant). It can be proven that there is a unique answer .
510. Inorder Successor in BST II
510. Inorder Successor in BST II
Description
Given a node
in a binary search tree, return the in-order successor of that node in the BST. If that node has no in-order successor, return null
.
285. Inorder Successor in BST
99. Recover Binary Search Tree
99. Recover Binary Search Tree
Description
You are given the root
of a binary search tree (BST), where the values of exactly two nodes of the tree were swapped by mistake. Recover the tree without changing its structure.
3213. Construct String with Minimum Cost
3213. Construct String with Minimum Cost
Description
You are given a string target
, an array of strings words
, and an integer array costs
, both arrays of the same length.
3212. Count Submatrices With Equal Frequency of X and Y
3212. Count Submatrices With Equal Frequency of X and Y
Description
Given a 2D character matrix grid
, where grid[i][j]
is either 'X'
, 'Y'
, or '.'
, return the number of submatrices that contain: