Amazon student Interview Question
StudentsCountry: Germany
Interview Type: Phone Interview
by adding int[] parent, you can run BFS from the start. Set all nodes' parent to -infinity, and start to 0. Whenever you visit a node because it is adjacent to another already visited node and its parent is not set, set the parent to the current node.
At the end, by finding end's parent, end's parent's parent's , .... you have the path backward. Reverse it.
- uuuouou March 05, 2014