i recently recieved the same question with different contraints in a test and was unable to solve it in those constraints
You are given a tree consisting of vertices
You can perform the following operation at most times: delete a single leaf of the tree (the operation can produce new leafs, that can be deleted later). The resulting tree must have as small diameter as possible. Find the minimum possible diameter.
Input Format The first line contains two space separated integers n and k. Each of the next lines contains two space separated integers , describing the current tree edge. It's guaranteed that the given graph is a tree.
Constraints
0<n<=1e5
0<k<n
Sample Input #00
4 0
1 2
2 3
4 3
Sample Output #00
3
Sample Input #01
4 1
2 3
4 3
1 4
Sample Output #01
2
approach : i tried to find the distance of all leafs from center of diameter and made 3 vector left, right and center where left stored the distances of nodes left of center and right stored the distances of nodes right of center and center of all those nodes connected to center node which are part of center node forest.I was able to solve 52/60 test cased and hitted a block can someone help in this



