Pergunta de entrevista da empresa Samsung Electronics

basic question on arrays and trees