Pergunta de entrevista da empresa Justworks

Leetcode question. They ask you to traverse a binary tree in various directions.