Why wouldn't you do a pre-order traversal and connect the appropriate nodes? When they say "recursion is key", that's actually misleading and this problem doesn't seem hard at all.
What am I missing?
What am I missing?
> Why wouldn't you do a pre-order traversal
Because then it wouldn't be O(n)