You are given the root of a binary tree and an integer depth.
Your task is to compute the sum of all node values located at the specified depth.
Note that:
depth 0.Return the total sum of node values at the given depth. If no nodes are found at the specified depth, return 0.
depth = 2
22
At depth 2, the nodes are 15 and 7. Their sum is 15 + 7 = 22.
depth = 2
3
The tree is 1 -> null -> 2 -> null -> 3. At depth 2, only node 3 exists. Its value is 3.
depth = 0
1
At depth 0, the only node is the root with value 1. Its sum is 1.
depth = 2
22