Skip to content

Practice Find Mode in Binary Search Tree

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#501
LeetCode Problem

Find Mode in Binary Search Tree

Problem Statement

Return all values with the greatest frequency in the given binary search tree, in any order. Duplicate values are allowed. Every left-subtree value is at most its node value, every right-subtree value is at least its node value, and the same property holds recursively. Follow-up: use no extra space beyond the output, excluding implicit recursion-stack space.

Source: Find Mode in Binary Search Tree on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
root = [1,null,2,2]
Output
[2]

# Example 2

Input
root = [0]
Output
[0]

Constraints

The number of nodes in the tree is in the range [1, 10^4].
-10^5 <= Node.val <= 10^5

Related LeetCode Problems

Practice more problems similar to Find Mode in Binary Search Tree.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.