This is the famous question that Homebrew author Max Howell famously got wrong in a Google Interview. Hopefully this prevents you from having the same misfortune!
Let's think about brute force-- how would we do it without any clever algorithms? We can start with a very basic input as follows:
SNIPPET
1 1
2 / \
32 3
