Pergunta de entrevista da empresa Affirm

Basic binary tree question, average complexity.