|  | 
|  | 
| back to board | Idea O(N) I got AC! It's nice problem!My algo works at O(3*N)=O(N).
 1)BFS from any vertex and find the most remote vertex (let V);
 2)BFS from V and find the most remote vertex (let U);
 3)Create path from U and V; vertex(vertexes) in the middle is answer.
 
 Edited by author 04.08.2015 12:56
 | 
 | 
|