Calculate farthest distance from a given node
Anonymous User
785

I was recently asked in an interview to calculate the farthest distance from a given node in a Binary tree. What's the best way to do this? I understand that the other end will be the part of diameter of the tree. So we can first calculate the diameter. Then calculate the distance between either ends of the diameter and the given node. Take the maximum. Any better solutions? Also, if this is there on LC can someone please give the link ? Not able to find it.

Comments (2)