I was once asked of this in an interview:
How to write a recursive function that
returns a linked list of nodes, when
given a binary tree of nodes?
(flattening the data) (Update: how about, don’t just traverse the tree and add the nodes to a global structure. Make the function totally recursive, and modifying the binary tree in place)
For some reason, I tend to need more than 3 to 5 minutes to solve any recursive problem. Usually, 15 to 20 minutes will be more like it. How could we attack this problem, such as a very systematic way of reaching a solution, so that they can be solved in 3 to 5 minute time frame?
Pretty much what @vittore did, but with single list allocation (but it will get reallocated internally, so..). This is also probably (brain malfunctioning) in order.