9
0 Likes

DSA Crash Course [Part 59] - Largest Component Approach

In this lesson, Alvin explores the strategy to solving the following interview problem:

Write a function, largest_component, that takes in the adjacency list of an undirected graph. The function should return the size of the largest connected component in the graph.

largest_component({
  0: [8, 1, 5],
  1: [0],
  5: [0, 8],
  8: [0, 5],
  2: [3, 4],
  3: [2, 4],
  4: [3, 2]
}) # -> 4