Pergunta de entrevista da empresa Amazon

Medium difficulty coding Q about connected components.