Dsa
Binary Search Tree
Warm-up
Sum of Nodes at Depth
Given the elements of a binary search tree in level order, calculate the sum of all nodes at a specified depth. The input consists of a space-separated list of integers and an integer specifying the depth.
Input format:
- The first line contains space-separated integers representing the level order traversal of the BST.
- The second line contains an integer depth.
Output format:
- Print a single integer which is the sum of the nodes at the specified depth.
Example:
Input:
10 5 15 3 7 12 20
2
Output:
36
Key concepts
binary_search_treetree_depthsummation
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