Dsa
Binary Search Tree
Easy
Archive Compliance Audit
A file archive stores metadata in a BST where each node is a File ID. A 'compliant archive' is defined as any subtree where every File ID in that subtree falls within a regulatory range [L, R]. Find the size (number of nodes) of the largest compliant archive in the tree.
Example:
Input:
20 10 30 5 15
5 18
Output: 3
Explanation: The subtree rooted at 10 has nodes {5, 10, 15}, all within [5, 18]. Its size is 3. The whole tree is not compliant because 20 and 30 are outside the range.
Key concepts
binary_search_treerecursionsubtree property
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now