Pergunta de entrevista da empresa Datadog

Binary tree question which was somewhat basic