Menu
Coddy logo textTech

Final Challenge #2

Lesson 9 of 9 in Coddy's Depth-First Search - Graph Algorithms course.

challenge icon

Challenge

Medium

One more challenge.

Write a function named largestComponent that takes n and the flat edges array (undirected) and returns the number of vertices in the largest connected component.

For example, with 5 vertices and edges [0,1, 0,2, 3,4] the components have sizes 3 and 2, so the answer is 3. An isolated vertex counts as a component of size 1.

Try it yourself

#include <stdlib.h>

int largestComponent(int n, int* edges, int edges_size) {
    // Write code here
    return 0;
}

All lessons in Depth-First Search - Graph Algorithms