Question d’entretien chez Amazon

Medium difficulty coding Q about connected components.