Find Mode in Binary Search Tree
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given the root of a non-empty binary search tree that may contain **duplicate** values. Here the BST property is non-strict: every value in a node's left subtree is <= the node's value, and every value in its right subtree is >= it.
Return every value that occurs the maximum number of times (the modes), as a list sorted in **ascending** order.
Follow-up: because an in-order traversal visits equal values consecutively, you can find the modes without a hash map (ignoring recursion stack space).
Examples
Constraints
- 1 <= number of nodes <= 10^4
- -10^5 <= Node.val <= 10^5
- The input satisfies the non-strict BST property described above
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.