Given the root of a binary tree, the value of a target node target, and an integer k, return an array of the values of all nodes that have a distance k from the target node. You can return the answer in any order.
Example 1
Input: root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, k = 2
Output: [7,4,1]
Explanation: From node 5, going down two edges reaches 7 and 4 (through 2). Going up to 3 and then down to 1 is also two edges. Nodes 6, 2 and 3 are only one edge away, so the answer is [7,4,1].
Example 2
Input: root = [1], target = 1, k = 3
Output: []
Explanation: The tree has a single node, so there is nothing 3 edges away from it, and the answer is [].
Example 3
Input: root = [1], target = 1, k = 0
Output: [1]
Explanation: With k = 0, the only node at distance 0 from the target is the target itself, so the answer is [1].
Build a parent map so we can traverse up. Then BFS from target for k levels.
Run checks all cases above. Submit evaluates all test cases.