Hello I am trying to solve the question :http://www.spoj.com/problems/PT07Z/ in SPOJ. I have used bfs to find the leaf node and then used bfs again to find the maximum path. I know there are other methods to solve this like simply finding the diameter of a tree in O(n) time. But I am trying this approach and I don't know what is causing the error. Here is a link to my solution http://ideone.com/QSJzDf.