Help understand and solve below (cpp soln must!)

Mr. Stark decided to go for morning walk everyday for a healthy lifestyle .He chose a community park which was near to his house .The park has multiple entrances and resting places in it collectively called as junctions of the park. All entrances and resting places are connected by walking tracks such that it is possible to go from each junction to other either directly or by a path. There are total N junctions in the park and N-1 walking tracks. Mr. Stark decided to enter from one entrance and exit from the other and walk the longest distance. Can you tell the longest distance Mr. Stark can walk in the park ?
Input Format

First line of the input contains a single integer representing the number of junctions N in the park. Next N-1 lines contains three integers A , B and C ,representing that junction A and junction B are connected by a bidirectional path of length C.
Constraints

0< N <=100000
1<= A,B <=N
1<= C <=100000
Output Format

Print a single integer representing the maximum distance Mr. Stark can walk .
Sample Input

5
1 2 1
2 5 10
2 3 2
3 4 3

Sample Output

15

Explanation

Entrances will be 1 and 3 .Path will be 1->2->3 .

hello @Kash-Moulik-3715574511847721 what you havent understood in this question ?

is this part of tree?

@Kash-Moulik-3715574511847721 yes
where are you solving this question ?
please share the link ?

it was part of codecapsule so i cant give u link now , only I had above given info

hey @Kash-Moulik-3715574511847721 as you have to prepare the tree so you have to find the diameter of the tree and that diameter of the tree will give you the answer .
maximum distance is called the diameter of the tree .

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.