Tap here to switch tabs
Problem
Submissions

Problem: Find Mode in Binary Search Tree

Try to solve the Find Mode in Binary Search Tree problem.

Statement

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 11 mode, return them in any order.

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 [1,104][1, 10^4].

  • −105≤-10^5 \leq Node.val ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Mode in Binary Search Tree

Try to solve the Find Mode in Binary Search Tree problem.

Statement

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 11 mode, return them in any order.

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 [1,104][1, 10^4].

  • −105≤-10^5 \leq Node.val ≤105\leq 10^5