Answer: Okta OA Question 2024 July | Trees | on-campus

Answer · Posted Jun 2026

Solution: Validate Binary Search Tree — DFS with Min/Max Bounds Approach A common mistake is to only compare a node with its direct parent. But every node in the left subtree must be less than all ancestors above it, not just the immediate parent. We use DFS with bounds. For every node, we pass a valid range [min, max]: At the root: range is (-∞, +∞). When going left: the node must be less than the current node, so update ...

The full answer & interview discussion are available to premium members.

Log in Create a free account