Pregunta de entrevista de TikTok

both rounds asked one programming problem about trees, fairly easy