Another assumption that I should have stated is that these are binary search trees, i.e. that their nodes are stored in order. The right children must be greater than the root which is greater than the left children. The trees you showed do both have the the same pre- and post-order, but it's not really valid because you aren't using the right node ordering. Your two trees were the right shape, but should look like this:
Code:
A C
/ \
B B
/ \
C A
in: A, B, C in: A, B, C
pre: A, B, C pre: C, B, A
post: C, B, A post: A, B, C
I wasn't focusing on two trees with the same pre- and post-ordering, but rather a tree for which either the pre- or post-order traversal was identical to the in-order traversal, as we have in the above example. In this case, even if you were given all 3 traversals, without knowing which was which, you couldn't reliably reconstruct the tree. Those two trees above have exactly the same 3 traversal paths, just with the pre- and post-orders switched.
Did you figure out the general case yet? It has to do with which two traversals you have.
This was actually a great problem, I've really been enjoying it.