Domanda di colloquio di Amazon

Medium difficulty coding Q about connected components.