Binary Tree Distance K from Target Node

Prereq: BFS on Tree

Given a binary tree, an integer that represents the target node's value, and an integer K, return a list of the values of all the nodes whose depth (level) is K away from the target node's depth. Order of returned nodes does not matter.

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro