Domanda di colloquio di Justworks

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