← 返回 amazon 的题目列表Maxdiff Value of Connected Components in Graph
类型:online_judge
Given three different inputs in a graph: a list of vertices with different integer values, a start vertex list, and an end vertex list. 1) Convert the list to a graph data structure, 2) iterate through each node to traverse connected components in the graph, capturing visited vertices and using max/min value to get max difference in a DFS algorithm, 3) return the max difference across connected components.
Example
Input
5
10 5 8 7 4
1 2 4
2 3 5