Skip to content

Latest commit

 

History

History
 
 

2017-01-27-k-distance-from-node

Print nodes at k distance from root

Given a root of a tree, and an integer k. Print all the nodes which are at k distance from root.

For example, in the below tree, 4, 5 & 8 are at distance 2 from root.

        1
      /   \
    2      3
  /  \    /
4     5  8