530 Minimum Absolute Difference in BST
Last updated
Was this helpful?
Last updated
Was this helpful?
Given a binary search tree with non-negative values, find the minimum between values of any two nodes.
Example:
Note:There are at least two nodes in this BST.
Complexity: O(n) time O(N) space
The Idea: If we run an in order traversal through the tree, the minimum difference is guaranteed to be between two adjacent elements. So that is what we do while maintaining the minimum value.