Please help me find what was wrong with this solution of mine?

I participated in this month’s long challenge. I got stuck on Minimum Subtree Cover (SUBTRCOV) problem. After lot of trials and analysis, I was able to solve for all testcases Except 1.

My Solution link:
https://www.codechef.com/viewsolution/47729616

I had spent couple of sleepless nights to find out what went wrong, or at least to comeup with a test case where my code would break.

Please help me in identifying the issue.

Summary of my approach:

  1. Find one of the two vertex of the diameter of the tree.
  2. Then fix the vertex from 1. as root of the tree.
  3. Calculate subtree node sizes and save it in each node of the tree.
  4. Do some sort of tree to linear decomposition (like heavy light decomposition)
  5. Lastly, in a while loop, keep adding the size of the Next longest linear node sequence and check if total node count is > k

Thanks in advance.