Pergunta de entrevista da empresa 23andMe

Tree/Graph question. where you had to sum the levels of each node