for the problem TREEDISTSET, the number of vertices is n.

and n <= 1000, which I was taking as a hint for N^2 solution.

I have gone through the solution which is O(N).

I want to know if there’s any O(N^2) solution possible without Diameter observation.

if yes can anyone share?

as N <= 1000, I was thinking of N^2 solutions the whole time.

Thanks in advance.