Search
⌘K

Leetcode 501. Find Mode in Binary Search Tree

Given a BST that may contain duplicate values, return all value(s) that occur most frequently (the mode(s)) in the tree. The key insight is that the BST's sorted order makes equal values consecutive (so an inorder traversal — even in O(1) extra space via Morris traversal for the follow-up — lets you count runs efficiently).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.