Back to problems

Maximum Difference Across Connected Components

Algorithm · Akuna Capital · Medium

Requirements You receive a graph through its number of vertices and its edge arrays. Determine every connected component, calculate the gap between the greatest and least node values in each one, and return the largest such gap. The HackerRank-style method declaration is: Vertex labels run from 1 through gNodes. The graph is bidirectional: edge i joins gFrom[i] and gTo[i]. A component consists of the largest possible set of vertices reachable from one another, whether…

Checking your access…