Given a tree with n nodes labeled 0..n-1 and an undirected weighted edge list (each edge [u, v, w]), return the diameter — the maximum total edge weight along any path between two nodes. The input is JSON {n, edges}.
Input: JSON {n, edges} with edges [u, v, w].
Output: Integer — the weighted diameter.
Input: {"n":4,"edges":[[0,1,2],[1,2,3],[1,3,4]]}
Output: 7
Explanation: Path 2-1-3 weighs 3+4=7.Input: {"n":1,"edges":[]}
Output: 0
Explanation: Single node.Input: {"n":2,"edges":[[0,1,5]]}
Output: 5
Explanation: Single edge.1<=n<=10^51<=w<=10^4edges form a tree