 All Problems
Find Mode in BST
easy
trees
dfs
binary search tree
amazon
google

Given the root of a BST (possibly with duplicates), return all modes (most frequently occurring values). Return in any order.

Example 1:

Input: 1 null 2 null null 2
Output: 2

Example 2:

Input: 1 1
Output: 1

Input format: Space-separated level-order values ("null" for absent nodes).

Output format: Space-separated modes in ascending order.

Run to check your code against the sample cases, or submit to run every case