Given the root of a binary search tree (BST) with duplicate values, return all the mode values (the most frequently occurred elements) in the tree.
If the tree contains more than
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with values less than or equal to the node’s value.
The right subtree of a node contains only nodes with values greater than or equal to the node’s value.
Both the left and right subtrees must also be binary search trees.
Constraints:
The number of nodes in the tree is in the range
Node.val
Given the root of a binary search tree (BST) with duplicate values, return all the mode values (the most frequently occurred elements) in the tree.
If the tree contains more than
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with values less than or equal to the node’s value.
The right subtree of a node contains only nodes with values greater than or equal to the node’s value.
Both the left and right subtrees must also be binary search trees.
Constraints:
The number of nodes in the tree is in the range
Node.val